Dim RS1 As ADODB.Recordset
dim strCn as string
dim sql as string
Set RS1 = New ADODB.Recordset
Set CNN = New ADODB.Connection
CNN.CursorLocation = adUseClient
strCn = "Provider=Microsoft.Jet.OLEDB.4.0Password=123data source = O:\schedule\BS Schedule\Marco Temp Data\537.mdbPersist Security Info=True" ----这里你适当改下
CNN.open (strCn )
sql = "select * from tablename "--表明改下
RS1.Open sql, CNN, adOpenKeyset, adLockOptimistic, adCmdText
rs.MoveFirst
For I = 1 To 1000
ComboBox1.AddItem RS1.Fields("品牌")
RS1.MoveNext
Next I
RS1.Close
Set RS1 = Nothing
Set DB1 = Nothing
Exit Sub
100:
MsgBox "找不到符合条件的记录", 1 + 16, "系统提示"
如果不行把 Set RS1 = Nothing
Set DB1 = Nothing 注释掉试试
第一步:连接数据库,下面是参考代码Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=Microsoft.Ace.OleDB.12.0Data Source=" &mypath
conn.ConnectionString = conn.ConnectionString &"Jet OLEDB:Database Password=1"
conn.Open
第二步:插入数据,参考代码如下:
Sql = "insert into skmxb (内部管理号,收款日期,金额"
Sql = Sql &") values ('" &nbglH &"', #" &Format(myD, "yyyy/mm/dd") &"#,"
Sql = Sql &jE
Sql = Sql &")"
conn.Execute Sql
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)