费尔干纳谷地事件:UPDATE 语句的语法错误

来源:百度文库 编辑:高校问答 时间:2024/07/11 17:31:24
程序我是在书上抄的可是不知为什么在更新数据时出现UPDATE 语句的语法错误的提示 谁能帮我看看吗? 谢拉
<%@ Import Namespace="System.Data.oledb" %>
<Script Language="VB" Runat="Server">
Dim myConnection as OledbConnection
Sub Page_Load(Sender as object,e as EventArgs)
Dim strCnn as string="Provider=Microsoft.Jet.OLEDB.4.0; "&"Data Source=e:\www\asd\学生.mdb"
myConnection=new OledbConnection(strCnn)
myConnection.open
if(not Page.IsPostBack)
call BindGrid
end if
End Sub
Sub BindGrid()
dim strSQL as string="Select * from 基本情况"
dim myCommand as OledbCommand=new OledbCommand(strSQL,myConnection)
dim myDataReader as OledbDataReader
myDataReader=myCommand.ExecuteReader()
myDataGrid.DataSource=myDataReader
myDatagrid.DataBind
myDataReader.close
end sub
Private Sub DataGrid_Edit(Sender as Object,e as DataGridCommandEventArgs)
myDataGrid.EditItemIndex=e.Item.ItemIndex
Call BindGrid
end sub
Private Sub DataGrid_Cancel(Sender as Object,e as DataGridCommandEventArgs)
myDataGrid.EditItemIndex=-1
Call bindgrid
end sub
Private Sub DataGrid_Update(Sender as Object,e as DataGridCommandEventArgs)
Dim ID,yw,shx,yy as String
Dim strSQL as string
Dim tempTextBox as TextBox
ID=e.Item.Cells(1).text
tempTextBox=e.Item.Cells(3).Controls(0)
yw=tempTextBox.Text
tempTextBox=e.Item.Cells(4).Controls(0)
shx=tempTextBox.Text
tempTextBox=e.Item.Cells(5).Controls(0)
yy=tempTextBox.Text
strSQL="Update 基本情况 set Chinese=" & yw & ",Math=" & shx & ",English" & yy & " where ID='" & ID & "'"
Dim myCommand as OledbCommand=new OledbCommand(strSQL,myConnection)
myCommand.ExecuteNonQuery()
myDataGrid.EditItemIndex=-1
Call BindGrid
end sub
</Script>
哇 我的问题刚发出去就有回应拉 我照你说的改了可还是显示UPDATE 语句的语法错误
Taylorqin也谢谢你的帮助,不好意思English好像后面漏了个“=”我原本是有的可能是复制时弄错了 Chinese,Math,English是int型的 ID是文本
可不知为什么还是出现“标准表达式中数据类型不匹配”的提示 问题还是没能解决只有请大家来帮忙看看拉 ~多谢拉

首先要看你的[基本情况]表里的Chinese,Math,English,ID字段的类型,到底是varchar还是int型,如果是字符型的那么传入的适用要用'单引号来限制,如果是数字型的那么就没必要加引号了,否则数据类型就错误了,还有就是范例里面的English好像后面漏了个等号吧

strSQL="Update 基本情况 set Chinese='" & yw & "',Math='" & shx & "',English='" & yy & "' where ID='" & ID & "'"

复制上面的,试看,应该得了