如何在VBA中执行SQL语句
1个回答
展开全部
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
'cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Extended Properties=Excel 8.0;" _
& "Data Source=" & ThisWorkbook.FullName
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Extended Properties=Excel 8.0;" _
& "Data Source=" & ThisWorkbook.FullName
Debug.Print ThisWorkbook.FullName
str1 = ActiveSheet.Range("A2")
'strSql = "Select * FROM [数据库$] Where 商品名称 like '%" & str1 & "%'"
Set rs = CreateObject("ADODB.Recordset")
'cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Extended Properties=Excel 8.0;" _
& "Data Source=" & ThisWorkbook.FullName
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Extended Properties=Excel 8.0;" _
& "Data Source=" & ThisWorkbook.FullName
Debug.Print ThisWorkbook.FullName
str1 = ActiveSheet.Range("A2")
'strSql = "Select * FROM [数据库$] Where 商品名称 like '%" & str1 & "%'"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |