'load datagrid for transport and travelling
If ComboBox1.Text = ComboBox1.Items(4) Then
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=circuit.mdb"
Try
cn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
ComboBox1.Items.Clear()
cm.Connection = cn
cm.CommandText = "select Number,Description from TransportTravelling"
rd = cm.ExecuteReader()
ComboBox1.Items.Clear()
While (rd.Read)
ComboBox1.Items.Contains("S13 Transport and Travelling")
End While
rd.Close()
If ComboBox1.Items.Count > 4 Then
ComboBox1.SelectedIndex = 4
End If
Try
Dim adp As New Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim dv As New DataView
adp.SelectCommand = cm
adp.Fill(ds, "dataset")
dv.Table = ds.Tables(0)
dv.Sort = "number"
DataGrid2.DataSource = dv
DataGrid2.Refresh()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cn.Close()
End Try
End If
Error handlingerror message
Page 1 of 1
2 Replies - 980 Views - Last Post: 29 April 2009 - 06:34 AM
#1
Error handling
Posted 29 April 2009 - 01:19 AM
hi there,can someone please assist.i have the code below which loads data into a combobox and on selected item it loads into a datagrid.but i get an error message saying:An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll, Additional information: Specified argument was out of the range of valid values. this is my code
Replies To: Error handling
#2
Re: Error handling
Posted 29 April 2009 - 04:10 AM
This could be throwing the exception:
Try using:
If ComboBox1.Text = ComboBox1.Items(4) Then
Try using:
If ComboBox1.SelectedIndex = 4 Then
#3
Re: Error handling
Posted 29 April 2009 - 06:34 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|