|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub update_recode()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim cnnstr As String
cnnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=d:\db1.accdb"
cnn.Open cnnstr
str1 = " UPDATE data SET xh='NB/S' where instr(1,size_code ,'NB/S')>0"
str2 = "UPDATE data SET xh='S' where instr(1,size_code ,'S')>0"
str3 = "UPDATE data SET xh='M' where instr(1,size_code ,'M')>0"
str4 = "UPDATE data SET xh='L' where instr(1,size_code ,'L')>0"
str5 = "UPDATE data SET xh='XL' where instr(1,size_code ,'XL')>0"
str6 = "UPDATE data SET xh='XXL' where instr(1,size_code ,'XL')>0"
rs.Open str1, cnn, adOpenKeyset, adLockOptimistic
Debug.Print rs.Fields(0).Value
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
运行到cnn.Open cnnstr
总是报错,说数据库格式不对,是不是 只能打开.mdb文件啊
求教达人
|
|