|
-
Jan 18th, 2007, 02:13 AM
#1
Thread Starter
New Member
Display Data Using Combobox Selection
'Am Using this code to fill combobox:
Dim str As String = "select * from login"
Dim com As SqlCommand = New SqlCommand(str, connection)
Dim adapt As SqlDataAdapter = New SqlDataAdapter(com)
Dim ds As DataSet = New DataSet
adapt.Fill(ds)
Dim i As Integer
ComboBox1.Items.Add("SELECT")
For i = 0 To ds.Tables(0).Rows().Count - 1
ComboBox1.Items.Add(ds.Tables(0).Rows(i).Item(1))
ComboBox1.ValueMember = "User_Id"
ComboBox1.DisplayMember = "User_name"
Next i
ComboBox1.SelectedIndex = 0
'am trying to display data to below textbox :
TextBox1.Text = ds.Tables"(0).Rows(0).Item(1)
TextBox2.Text = ds.Tables(0).Rows(0).Item(2)
TextBox3.Text = ds.Tables(0).Rows(0).Item(3)
TextBox4.Text = ds.Tables(0).Rows(0).Item(4)
TextBox5.Text = ds.Tables(0).Rows(0).Item(5)
TextBox6.Text = ds.Tables(0).Rows(0).Item(6)
TextBox7.Text = ds.Tables(0).Rows(0).Item(7)
TextBox8.Text = ds.Tables(0).Rows(0).Item(8)
TextBox9.Text = ds.Tables(0).Rows(0).Item(9)
TextBox10.Text = ds.Tables(0).Rows(0).Item(10)
TextBox11.Text = ds.Tables(0).Rows(0).Item(11)
IF I TRY TO SELECT FROM COMBOBOX OTHER THAN DEFAULT"SELECT" OPTION, IT GIVES ERROR LIKE:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
Additional information: There is no row at position 0.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|