problem entering data in access through vb.net - TechRepublic
Question
February 23, 2008 at 01:46 AM
sarangs_phadnis

problem entering data in access through vb.net

by sarangs_phadnis . Updated 18 years, 5 months ago

Dim m_strConn As String = “C:\Documents and Settings\Reflexresources\My Documents\test.mdb”
Dim m_cn As OleDbConnection = New OleDbConnection(“Provider=Microsoft.Jet.Oledb.4.0;data source=” & m_strConn & “”)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim cmInsert As OleDbCommand = New OleDbCommand
Dim tempnum As Integer
cmInsert.CommandText = “insert into test1 values(‘” & TextBox1.Text & “‘)”
cmInsert.CommandType = CommandType.Text
cmInsert.Connection = m_cn
m_cn.Open()
cmInsert.ExecuteNonQuery()
MsgBox(“jai ho”)
m_cn.Close()
Catch
Dim ex As SystemException
MessageBox.Show(ex.Message)
End Try

End Sub

An unhandled exception of type ‘System.NullReferenceException’ occurred in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an object.

What to do? Where the problem lies?

This discussion is locked

All Comments