昨晚研究了一下还是不行..........删除不了!!!!!!那位高手可以帮我看看吗???
Private Sub DataGrid1_delete(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
TextBox5.Text = e.CommandArgument.ToString()
Dim conn As New OleDbConnection
Dim comm As New OleDbCommand
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\留言.mdb")
conn.Open()
comm.Connection = conn
comm.CommandText = "delete from 留言表 where 编号='" + e.CommandArgument.ToString() + "'"
comm.CommandText = "updata from 留言表 "
End Sub
我加上也不行啊
TextBox5.Text = e.CommandArgument.ToString()
Dim conn As New OleDbConnection
Dim comm As New OleDbCommand
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\留言.mdb")
conn.Open()
comm.Connection = conn
comm.CommandText = "delete from 留言表 where 编号='" & TextBox2.Text & "'"
'comm = New OleDbCommand(comm.CommandText, conn)
Try
comm.ExecuteNonQuery()
Catch
Response.Write("更新不成功!!")
End Try
conn.Close()
'页面重定向到论坛页面
Response.Redirect("adminindex1.aspx")
后来我改成这样拉!!!!!!!!!! 出现了至少有一个参数没指定数值!
当我在SQL语句中直接把a改为1........或者其它数字时就可以删除!!!!!
我想应该错误出在TextBox5.Text = e.CommandArgument.ToString()....a = Convert.ToInt32(TextBox5.Text)这两句中...请大侠指教!!!!!!!!!!!
TextBox5.Text = e.CommandArgument.ToString()
Dim a As Integer
a = Convert.ToInt32(TextBox5.Text)
Dim conn As New OleDbConnection
Dim comm As New OleDbCommand
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\留言.mdb")
conn.Open()
comm.Connection = conn
comm.CommandText = "delete from 留言表 where 编号=a "
comm.ExecuteNonQuery()
conn.Close()
Response.Redirect("adminindex1.aspx")