SQL语句在VB中为什么老是提示select附近语法错误但在SQL中执行此SQL语句没有错啊 提示Adodc1.Refresh失败
DimsqlAsStringDimcnn1AsNewADODB.ConnectionOnErrorResumeNextcnn1.Open"Provider=SQLOLED...
Dim sql As String
Dim cnn1 As New ADODB.Connection
On Error Resume Next
cnn1.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=raindata;Data Source=5AA1IKCBWW0J7MU" '连接数据库
sql = "Select * from raindata_d where 日期 ='" & Format(DTPicker1, "yyyy-MM-dd") & "'"
Form2.Adodc1.RecordSource = sql
Form2.DataGrid1.Refresh
Form2.Adodc1.Refresh 展开
Dim cnn1 As New ADODB.Connection
On Error Resume Next
cnn1.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=raindata;Data Source=5AA1IKCBWW0J7MU" '连接数据库
sql = "Select * from raindata_d where 日期 ='" & Format(DTPicker1, "yyyy-MM-dd") & "'"
Form2.Adodc1.RecordSource = sql
Form2.DataGrid1.Refresh
Form2.Adodc1.Refresh 展开
展开全部
sql = "Select * from raindata_d where 日期 =#" & DTPicker1.Value & "#"
请把问题专到VB分类,谢谢
如满意请点一下满意按钮,如不满意请追问,谢谢
请把问题专到VB分类,谢谢
如满意请点一下满意按钮,如不满意请追问,谢谢
追问
好像不是这个原因,我之前有在属性表中设置了Adodc1.RecordSource连接然后就无法刷新,我试了下把这个连接去掉又没问题了,可是会出现提示:“[ADODC]没有指定记录源;[ADO]没有为命令对象设置命令” 这个提示怎么忽略?
追答
加一句
Adodc1.CommandType = adCmdText
Form2.Adodc1.RecordSource = sql
Form2.Adodc1.Refresh
Form2.DataGrid1.Refresh
请把问题专到VB分类,谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询