用SQL查询语句更新ACCESS数据库,怎么更新不了啊
定义变量如下:
Public Cn As Connection
Public rs As Recordset
假设rs当中已经有了一些记录,用datagrid控件来反映rs的变化情况。我用了如下的更新语句:
Dim str As String
Dim number As Long
number = rs("No")
str = "Update " & TableDictName & " Set " & _
"No=" & Val(Text_No.Text) & "," & _
"W_C='" & Text_W_C.Text & "'," & _
"G_C='" & Text_G_C.Text & "'," & _
"E_C='" & Text_E_C.Text & "'," & _
"W_E='" & Text_W_E.Text & "'," & _
"G_E='" & Text_G_E.Text & "'," & _
"E_E='" & Text_E_E.Text & "'," & _
"DEF='" & Text_DEF.Text & "'," & _
"FIRST_SEM='" & Text_FIRST_SEM.Text & "' " & _
"where No=" & number
Cn.Execute str
str="select * from dict"
set rs=cn.Execute str
Set Form_main.DataGrid.DataSource = rs
执行该程序段之后,发现应该得到修改的记录的相应字段没有变化。不知道为什么,请各位大虾指点。我想问题是不是出在where 语句之后的long类型的变量身上,因为当我用字符型的条件放在where之后的时候,就能得到正确的修改。