我是VB.net的新手,我正在使用VS 2010,我希望使用以下字段(Message = mediumtext,Phone = varchar 15)将一些数据保存到我的MySQL数据库表(Inbox)中,但它说
对象引用未设置为对象的实例
Public Sub OpenRecord(ByVal sql As String)
Connection() //this to call my database connection
Try
If rs.State = 1 Then rs.Close()
rs.Open(sql, con, 1, 2)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
End Try
End Sub
然后我从Button_Click事件中调用上面的SUB
OpenRecord("Select * From Inbox")
With rs
.AddNew() //this is where i got the error and if i remove this line the next two lines will have the same error.
.Fields("Message").Value = Me.txtmsg.Text
.Fields("Phone").Value = Me.txtnum.Text
.Update()
End With