我有一个表(DataGrid)有更改功能。
UpDate得事件程序是这样得。
×××××××××××××××××××××××××××××××××××××××××××
Sub UpDateData(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim Conn As SqlConnection = New SqlConnection("server=008-hansipin;user id=sa;password=guiche;database=#Data")
Conn.Open()
Dim Cmd As SqlCommand = New SqlCommand("UPDATE DataList SET AddMoney=@AddMoney,Beizhu=@Beizhu WHERE id=@Key", Conn)
Cmd.Parameters.Add(New SqlParameter("@AddMoney", SqlDbType.Text, 3))
Cmd.Parameters.Add(New SqlParameter("@Beizhu", SqlDbType.VarChar, 255))
Cmd.Parameters.Add(New SqlParameter("@Key", SqlDbType.Text, 4)) Cmd.Parameters("@Key").Value = DataGrid1.DataKeys(E.Item.ItemIndex)
Dim AddMY As TextBox
AddMY = CType(E.Item.FindControl("MYTextBox"), TextBox)
Cmd.Parameters("@AddMoney").Value = Convert.ToString(AddMY.Text)
Dim BZ As TextBox
BZ = CType(E.Item.FindControl("BZTextBox"), TextBox)
Cmd.Parameters("@Beizhu").Value = Convert.ToString(BZ.Text)
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
OpenDataBase_And_BindToDataGrid()
End Sub
×××××××××××××××××××××××××××××××××××××××××××但是更改过表提交之后确出现如下提示:×××××××××××××××××××××××××××××××××××××××××××
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: 不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。Source Error:
Line 105: BZ = CType(E.Item.FindControl("BZTextBox"), TextBox)
Line 106: Cmd.Parameters("@Beizhu").Value = Convert.ToString(BZ.Text)
Line 107: Cmd.ExecuteNonQuery()
Line 108: Conn.Close()
Line 109: DataGrid1.EditItemIndex = -1
××××××××××××××××××××××××××××××××××××××××××××
我去差了一下,Is Null和Like得运算符用法,但是还是搞不清楚。
麻烦大家讲讲。
UpDate得事件程序是这样得。
×××××××××××××××××××××××××××××××××××××××××××
Sub UpDateData(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim Conn As SqlConnection = New SqlConnection("server=008-hansipin;user id=sa;password=guiche;database=#Data")
Conn.Open()
Dim Cmd As SqlCommand = New SqlCommand("UPDATE DataList SET AddMoney=@AddMoney,Beizhu=@Beizhu WHERE id=@Key", Conn)
Cmd.Parameters.Add(New SqlParameter("@AddMoney", SqlDbType.Text, 3))
Cmd.Parameters.Add(New SqlParameter("@Beizhu", SqlDbType.VarChar, 255))
Cmd.Parameters.Add(New SqlParameter("@Key", SqlDbType.Text, 4)) Cmd.Parameters("@Key").Value = DataGrid1.DataKeys(E.Item.ItemIndex)
Dim AddMY As TextBox
AddMY = CType(E.Item.FindControl("MYTextBox"), TextBox)
Cmd.Parameters("@AddMoney").Value = Convert.ToString(AddMY.Text)
Dim BZ As TextBox
BZ = CType(E.Item.FindControl("BZTextBox"), TextBox)
Cmd.Parameters("@Beizhu").Value = Convert.ToString(BZ.Text)
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
OpenDataBase_And_BindToDataGrid()
End Sub
×××××××××××××××××××××××××××××××××××××××××××但是更改过表提交之后确出现如下提示:×××××××××××××××××××××××××××××××××××××××××××
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: 不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。Source Error:
Line 105: BZ = CType(E.Item.FindControl("BZTextBox"), TextBox)
Line 106: Cmd.Parameters("@Beizhu").Value = Convert.ToString(BZ.Text)
Line 107: Cmd.ExecuteNonQuery()
Line 108: Conn.Close()
Line 109: DataGrid1.EditItemIndex = -1
××××××××××××××××××××××××××××××××××××××××××××
我去差了一下,Is Null和Like得运算符用法,但是还是搞不清楚。
麻烦大家讲讲。
解决方案 »
- ASP.net(gridview导出的execl没有数据)求解给分
- asp.net(c#)想做一个导航栏 鼠标移动到那个项那个就变英文鼠标移开变回中文
- 未知的服务器标记
- asp.net(C#) 写xml文件保存时中文出现乱码
- 我的TreeView同时绑定了不同的Text和相同的Value,怎么得到的Text的值都是第一个节点的值
- 什么叫RC版本?
- 关于在带框架网页中https页面,急!!!
- 登陆成功后存session,点击后退按钮,又要重新登陆 ,为什么
- 重装后出现的问题,各位大大来帮帮忙啊!
- 我想用一个公共函数在为每个页面生成css,但处为什么response的时候出错?
- 为什么老掉数据?
- 有两个表分别如tablea、tableb所示,如何得到表3所示的结,SQL语句应该怎么写?
妈妈得。流一天。给来得都给分~!