another error im afraid:
System.ArguementOutOfRangeException: Index was out of range.Must be non negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
i declared i as an integer(which wasnt in your code) as it wasnt recognising i,might that have somethin to do with it?
Code:Imports System.Data Public Class Form1 Dim Ping As Net.NetworkInformation.Ping Dim pReply As Net.NetworkInformation.PingReply Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer 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) Ping = New Net.NetworkInformation.Ping Dim dgvr As DataGridViewRow For i = 0 To ds.Tables("monitor").Rows.Count - 2 Next dgvr = New DataGridViewRow 'Creates a new row DataGridView1.Rows.Add(dgvr) 'Add the row Try pReply = Ping.Send(ds.Tables("monitor").Rows(i).Item(0)) 'Sends the ping to the current item DataGridView1.Rows.Item(i).Cells(0).Value = ds.Tables("monitor").Rows(i).Item(0) 'Updates the value of the new Item DataGridView1.Rows.Item(i).Cells(1).Value = pReply.Status 'The value of the status returned If pReply.Status <> Net.NetworkInformation.IPStatus.Success Then 'Sets the color of the cell DataGridView1.Rows.Item(i).Cells(1).Style.BackColor = Color.Red Else DataGridView1.Rows.Item(i).Cells(1).Style.BackColor = Color.Green End If ds.Tables("monitor").Rows(i).Item(1) = pReply.Status 'Write in the original datatable da.Update(ds, "monitor") 'Updates the database Catch ex As Exception MessageBox.Show(ex.ToString()) End Try 'Next 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
