VB里DATAGRID有关的问题

在上一个界面中使用DATAGRID空间来显示学生成绩,界面内含修改成绩和添加成绩两个按钮,由于添加成绩和修改成绩功能基本相同,所以使用同一窗体编辑,运行时可以成功添加成绩,但是在DATAGRID控件中选择了学生后点饥修改成绩后提示:标题为ADODC2 第一行:“=”附近有语法错误 代码如下:
Dim strcid As String
Dim strcourse As String
Dim strclname As String
Dim strstid As String

Private Sub cmdok_Click()
If cmbstname.Text = "" Or txtscore = "" Then
MsgBox "没有选择学生或者没有成绩", , "添加成绩"
Exit Sub
End If
If addedit = True Then
adoscore.Recordset.AddNew
adoscore.Recordset.Fields("st_id") = Trim(adostname.Recordset.Fields("st_id"))
adoscore.Recordset.Fields("c_no") = Trim(strcid)
adoscore.Recordset.Fields("score") = txtscore
adoscore.Recordset.Update
adostname.RecordSource = "select * from st_info where cl_Name='" _
& strclname _
& "'and st_id not in (select st_id from s_c_info where c_no='" _
& strcid & "')"
adostname.Refresh
txtscore = ""
Else
adoscore.Recordset.Fields("score") = txtscore
adoscore.Recordset.Update
End If

End Sub

Private Sub Form_Load()
strclname = Trim(frmscorem.cmbcls.Text)
strcourse = Trim(frmscorem.cmbcname.Text)
strcid = Trim(frmscorem.cmbcname.BoundText)
lbcname.Caption = strcourse
lbclass.Caption = strclname
If addedit = True Then
adostname.RecordSource = "select * from st_info where cl_name='" & strclname _
& "'and st_id not in (select st_id from s_c_info where c_no='" _
& strcid & "')"
adostname.Refresh
adoscore.RecordSource = "select * from s_c_info"
adoscore.Refresh
txtscore = ""
Else
strstid = frmscorem.adodcscore.Recordset.Fields("学号")
adostname.RecordSource = "select * from st_info where st_id='" & strstid & "'"
adostname.Refresh
adoscore.RecordSource = "select * from s_c_info where st_id='" & strstid _
& "'and c_no='" & strcid & "'"
adoscore.Refresh
cmbstname.Text = adostname.Recordset.Fields("st_name")
txtscore = adoscore.Recordset.Fields("score")
End If

End Sub
不是AND前面的问题 含有DATAgrid控件的界面的代码太长发不上来 我之前的一个问题里有那些代码 http://zhidao.baidu.com/question/101885256.html

第1个回答  2009-06-17
adoscore.Recordset.Update
adostname.RecordSource = "select * from st_info where cl_Name='" _
& strclname _
& "'and st_id not in (select st_id from s_c_info where c_no='" _
& strcid & "')"
adostname.Refresh
/以上是你的原文,此处and前和引号之间缺少空格
& "' and st_id not in (select st_id from s_c_info where c_no='" _
/增加了空格/
/下面都是,and前的引号和and 之间缺少空格/
相似回答
大家正在搜