数据库更新不了!
部分代码:Sub Sure_Click(ByVal Sender As Object, ByVal E As EventArgs) Handles Sure.Click
Dim StrCnn As String
Dim Sql As String
Dim theText As String
Dim theObj As String
Dim theFace As String
Dim theFont As String
Dim FacePic As String
theText = T1.Text '获取用户的发言信息
theObj = drop.SelectedItem.Text '获取用户所选择的聊天对象
theFace = drop1.SelectedItem.Text '获取用户所选择的表情
theFont = drop2.SelectedItem.Value '获取用户所选择的字体颜色
FacePic = drop3.SelectedItem.Value '获取用户所选择的贴图
'连接数据库
StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("lts.mdb")
Cnn = New OleDbConnection(StrCnn)
Cnn.Open()
'保存用户的发言信息,其中发言人通过Session变量username来获取
Sql = "insert into content(Talker,Toobj,Color,Content,FaceStr,FacePic) values('" & Session("username") & "','" & theObj & "','" & theFont & "','" & theText & "','" & theFace & "','" & FacePic & "')"
Cmd = New OleDbCommand(Sql, Cnn)
Cmd.ExecuteNonQuery()
Cnn.Close()
T1.Text = "" '清空信息文本框,以便再次输入
End Sub
错误信息:
字段 'content.Talker' 不能是零长度的字符串。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 字段 'content.Talker' 不能是零长度的字符串。
源错误:
行 71: Sql = "insert into content(Talker,Toobj,Color,Content,FaceStr,FacePic) values('" & Session("username") & "','" & theObj & "','" & theFont & "','" & theText & "','" & theFace & "','" & FacePic & "')"
行 72: Cmd = New OleDbCommand(Sql, Cnn)
行 73: Cmd.ExecuteNonQuery()
行 74: Cnn.Close()
行 75: T1.Text = "" '清空信息文本框,以便再次输入