|
-
Jul 20th, 2004, 09:10 PM
#1
Thread Starter
Addicted Member
Allow to select title from comboBox then display for the select title
Hi..
I have one problem...
how to allow the user to select title from comboBox then display acording for the select title to the textbox...
I read that need to create two data Adapters...
I configure one with the SQl statement:
Select TItle, Author, ISBN FROM Books
WHERE Title = ?
But how to configure the other data adapter?
When i run with only one data Adapter, i get the error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
The error point to the code below Private Sub frmBooks_load(....
......dbRnR.Fill(DsBooks1) =error
Thanks
-
Jul 20th, 2004, 09:17 PM
#2
this one?
VB Code:
Dim cn As New SqlConnection("integrated security=true;initial catalog=northwind;data source=...")
Dim da As New SqlDataAdapter("select * from sampletable", cn)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable()
da.Fill(dt)
Dim dr As DataRow
For Each dr In dt.Rows
ComboBox1.Items.Add(dr(1))
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.SelectedItem
End Sub
-
Jul 20th, 2004, 09:42 PM
#3
Thread Starter
Addicted Member
Allow to select title from comboBox then display for the select title
Thanks...
But i used OleDbConnection to connect not SqlConnection..
and i used the data Adapter wizard to edit th SQL code...
is it still the same code to use ?....
This is the code i write into...
Code:
Private Sub frmBooks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'dbRnR.Fill(DsBooks1) 'error pointed when running
DisplayRecordPosition()
End Sub
Private Sub cboTitle_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTitles.SelectedIndexChanged
DsBooks1.Clear()
dbRnR.SelectCommand.Parameters("Title").Value = cboTitles.Text
dbRnR.Fill(DsBooks1)
End Sub
Last edited by toytoy; Dec 3rd, 2004 at 08:28 AM.
-
Jul 20th, 2004, 09:48 PM
#4
its just they same..
just change the sql to oledb
-
Jul 20th, 2004, 11:42 PM
#5
Thread Starter
Addicted Member
Hi...
How come still cannot....
i change the sql to ole and run....
It states that both connection and adapter are not defined..
Thanks
-
Jul 21st, 2004, 12:03 AM
#6
VB Code:
Imports System.Data.OleDb
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
|