VB中AdodcGrid.Refresh有问题,提示对象Refresh的方法IAdodc失败,代码如下
PrivateSubForm_Load()DimstrSnoAsStringDimstrSelectAsStringstrSno=Trim(Form1.Text1.Tex...
Private Sub Form_Load()
Dim strSno As String
Dim strSelect As String
strSno = Trim(Form1.Text1.Text)
strSelect = "select Sname,Cname,Ccredit,Grade from Student s join SC" & "on s.sno=SC.sno join Course c on c.cno=SC.cno where" & "SC.cno='" & strSno & "'"
AdodcGrid.CommandType = adCmdText
AdodcGrid.RecordSource = strSelect
AdodcGrid.Refresh
Set DataGrid1.DataSource = AdodcGrid
Call InitGrid
End Sub 展开
Dim strSno As String
Dim strSelect As String
strSno = Trim(Form1.Text1.Text)
strSelect = "select Sname,Cname,Ccredit,Grade from Student s join SC" & "on s.sno=SC.sno join Course c on c.cno=SC.cno where" & "SC.cno='" & strSno & "'"
AdodcGrid.CommandType = adCmdText
AdodcGrid.RecordSource = strSelect
AdodcGrid.Refresh
Set DataGrid1.DataSource = AdodcGrid
Call InitGrid
End Sub 展开
3个回答
2012-06-26
展开全部
问题可能出在SQL语句上,单独执行看是否取到了数据;注意数据类型,文本要单引号,数字不用单引号的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
缺少应有的空格:
... s join SC[] " & "on s.sno=SC.sno join Course c on c.cno=SC.cno where[]" & ...
正确的写法必须保证应有的空格:
... s join SC " & "on s.sno=SC.sno join Course c on c.cno=SC.cno where " & ...
... s join SC[] " & "on s.sno=SC.sno join Course c on c.cno=SC.cno where[]" & ...
正确的写法必须保证应有的空格:
... s join SC " & "on s.sno=SC.sno join Course c on c.cno=SC.cno where " & ...
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库没连接?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询