i have tried altering some code i have to ping an ip address and store the result in an access db.i had it working when i had the ip hardcoded in as a string but I am now gettin an error.instead of having the ip address hardcoded in to the code i want it to be read in from the access db but im now getting this error:System.nullreferenceException
bject reference not set to an instance of an object at...button1.click event args e
i have underlined the piece of code i tried to change
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
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim con As New OleDb.OleDbConnection
Try
Ping = New Net.NetworkInformation.Ping
pReply = Ping.Send(ds.Tables("monitor").Rows(0).Item(0))
Label1.Text = pReply.Status.ToString
If pReply.Status = Net.NetworkInformation.IPStatus.Success Then
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.ToString())
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