报错,怎么解决呀?
我备份数据库的时候关闭连接就报错Adodc.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; data source=" + App.Path + _
"\information.mdb;" + "JET OLEDB:DataBase Password=yangsida "
Adodc.CursorType = adOpenStatic
Adodc.CommandType = adCmdText
Adodc.RecordSource = "select stuID as 学号,stuName as 姓名,stuSex as 性别,stuAge as 年龄,stuXueli as 学历,stuAdress as 家庭住址," + _
"stuPhone as 联系电话,stuQQ as QQ,stuEmail as Email from stuinfo order by stuID"
Adodc.Refresh
Set dgFirst.DataSource = Adodc
dgFirst.Refresh
Adodc.Recordset.Close
Adodc.ConnectionString = ""
Adodc.RecordSource = ""
就是这句
Set Adodc.Recordset = Nothing
怎么在备份数据库的时候不抱错又可以将其备份? --------------------编程问答-------------------- 把这句去掉 --------------------编程问答-------------------- 不行啊,删了这句就关闭不了数据库 --------------------编程问答-------------------- adodc没有关的,改用adodb吧 --------------------编程问答-------------------- --------------------编程问答-------------------- Adodc.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; data source=" + App.Path + _
"\information.mdb;" + "JET OLEDB:DataBase Password=yangsida "
Adodc.CursorType = adOpenStatic
Adodc.CommandType = adCmdText
Adodc.RecordSource = "select stuID as 学号,stuName as 姓名,stuSex as 性别,stuAge as 年龄,stuXueli as 学历,stuAdress as 家庭住址," + _
"stuPhone as 联系电话,stuQQ as QQ,stuEmail as Email from stuinfo order by stuID"
Adodc.Refresh
Set dgFirst.DataSource = Adodc
dgFirst.Refresh
Adodc.Recordset.Close
Set Adodc.Recordset = Nothing '改变一下位置看看
Adodc.ConnectionString = ""
Adodc.RecordSource = ""
就是这句
--------------------编程问答-------------------- NO,还是报一样的错误 --------------------编程问答-------------------- 你这代码是备份数据库吗? --------------------编程问答-------------------- 看个例子
Private Sub Backup_Click()--------------------编程问答-------------------- 改用adodb吧
Dim mfile As String, mfile2 As String
On Error Resume Next
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "Access文件(*.mdb)|*.mdb"
CommonDialog1.ShowSave
mfile = App.Path & "\db2.mdb" '要备份的文件为当前文件夹下的 db1.mdb
mfile2 = CommonDialog1.FileName '得到目标文件的路径
If Trim(mfile2) = "" Then Exit Sub
If Dir(mfile2) <> "" Then
If MsgBox(Dir(mfile2) & " 文件已经存在,是否替换?", vbYesNo, "警告") = vbNo Then Exit Sub
End If
Dim buff() As Byte, i As Long
i = FileLen(mfile)
ReDim buff(i - 1)
Open mfile For Binary As #1
Get #1, , buff
Close #1
Open mfile2 For Binary As #1
Put #1, , buff
Close #1
MsgBox "备份完毕!"
End Sub
要先引用 microsoft activex data objects 8.0 library
--------------------编程问答-------------------- adodc不是adodb,是不能nothing的,要么改用adodb,要么代码前加一句屏蔽错误
On Error Resume Next
实际上8楼的代码就可以,lz的代码只有关闭,没见备份 --------------------编程问答-------------------- ........................................ --------------------编程问答-------------------- 直接将数据库文件.mdb备份一下就好了. --------------------编程问答-------------------- http://download.csdn.net/source/1498324
补充:VB , 控件