i have the following code but when i select button1 i get the following error: Null Reference Exception was unhandled-object reference not set to an instance of an object. - any idea's how to fix it ??
*i have underlined the line of code that is highligted when the error occurs
Code:Imports System.Data Public Class Form1 Dim Ping As Net.NetworkInformation.Ping Dim pReply As Net.NetworkInformation.PingReply Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Public Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\mhorgan\Desktop\VBtest.mdb" con.Open() sql = "SELECT * FROM tblone" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "monitor") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Ping = New Net.NetworkInformation.Ping pReply = Ping.Send("143.239.167.240") Label1.Text = pReply.Status.ToString If pReply.Status = Net.NetworkInformation.IPStatus.Success Then Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\mhorgan\Desktop\VBtest.mdb" con.Open() sql = "SELECT * FROM tblone" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "monitor") Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("monitor").Rows(0).Item(1) = Label1.Text da.Update(ds, "monitor") Else Label1.BackColor = Color.Red End If Catch ex As Exception MessageBox.Show(ex.InnerException.Message) End Try End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\mhorgan\Desktop\VBtest.mdb" con.Close() End End Sub End Class




Reply With Quote
