Hey folks got a problem i cant understand
first i shortly try to explain my prog...
I got two datagrids the first is to display what has been retrived by a selectcommand from a dataset. The other dataset is to display data that is "bound" to the selected row in datagrid1..
e.g i search in my dataset all machines that are located at "elmstreet" in the first datagrid there would come thre machines
machine 1, serialnr 23423
machine 2, serialnr 23424
machine 3, serialnr 23425
now i click on (rowheader0) machine1 and want to se some data in datagrid 2.
here is my code
im filling datagrid1 and it works fine but when i search an fill datagrid1 again i got this error
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
when i continue everything runs fine with no error! ????
I dont know where it goes wrong! I have the zipped the applikation maybe soemone knows how to fix it!
first i shortly try to explain my prog...
I got two datagrids the first is to display what has been retrived by a selectcommand from a dataset. The other dataset is to display data that is "bound" to the selected row in datagrid1..
e.g i search in my dataset all machines that are located at "elmstreet" in the first datagrid there would come thre machines
machine 1, serialnr 23423
machine 2, serialnr 23424
machine 3, serialnr 23425
now i click on (rowheader0) machine1 and want to se some data in datagrid 2.
here is my code
Code:
Dim auswahl
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
/*Form_Load fills the dataset "PAGeraete" with all entries in the database Table "PAGeraete"! Sets The Data
source for the Datagrid1
Try
GeraeteAdapter.SelectCommand.Parameters.Clear()
GeraeteAdapter.SelectCommand.CommandText = "SELECT GeraeteID, GeraeteTyp, Standort, [LA-Nr], [DM-Nr], Flasche1, Flasche2, Bodyguard, Hersteller, Indienst FROM(PAGeraete) ORDER BY GeraeteID"
DataGrid1.DataSource = (PAGeraete1.PAGeraete)
PAGeraete1.Clear()
GeraeteAdapter.Fill(PAGeraete1)
Catch fillexception As System.Exception
MsgBox("Exception Caught: " & fillexception.Message)
End Try
OleDbConnection2.Open()
DatenAdapter.SelectCommand.Parameters("Geraetenr").Value = 1
OleDbSelectCommand2.ExecuteNonQuery()
DataGrid2.DataSource = (PaDaten1.PADaten)
PaDaten1.Clear()
DatenAdapter.Fill(PaDaten1)
OleDbConnection2.Close()
End Sub Form1_Load
Private Sub Datagrid1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
Try
auswahl = DataGrid1(DataGrid1.CurrentRowIndex, 0)
Catch e1 As System.IndexOutOfRangeException
MsgBox("Thisis caught an error: " & e1.Message)
MessageBox.Show(auswahl)
End Try
Datafill()
End Sub
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
when i continue everything runs fine with no error! ????
I dont know where it goes wrong! I have the zipped the applikation maybe soemone knows how to fix it!