|
-
Mar 3rd, 2010, 01:04 PM
#1
Thread Starter
Lively Member
VB, using database... Inner join help!
Right now I have a listbox,
this listbox displays surnames... when clicked it displays their address.
I have a 'confirm' button... to confirm the right person..
And now I need more information to come up when that's clicked... giving data from another table.... I'm sure I need to use an inner join but I don't quite understand how to do it, any help is much appreciated....
Here's what I have so far....
Dim ConnectionString As String
Dim SQLString As String
Dim cmd As System.Data.OleDb.OleDbCommand
Dim conn As System.Data.OleDb.OleDbConnection
Dim dr As System.Data.OleDb.OleDbDataReader
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
ConnectionString += "Source=" & "Opticians.accdb "
conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
'AddressTextBox.Text = ListBoxOutput.Text.Substring(0, 5)
AddressTextBox.Text = ListBoxOutput.Text
SQLString = "SELECT * FROM CustomerTable "
SQLString += "Where '" & AddressTextBox.Text & "'"
SQLString += "= Surname"
Try
conn.Open()
If ConnectionState.Open.ToString = "Open" Then
cmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
dr = cmd.ExecuteReader()
If dr.HasRows Then
dr.Read()
If Not IsDBNull(dr.Item("Street")) Then
AddressTextBox.Text = dr.Item("Street").ToString
End If
If Not IsDBNull(dr.Item("Town")) Then
Address2TextBox.Text = dr.Item("Town").ToString
End If
If Not IsDBNull(dr.Item("County")) Then
Address3TextBox.Text = dr.Item("County").ToString
End If
End If
End If
Catch ex As Exception
End Try
Last edited by Kielo; Mar 3rd, 2010 at 01:06 PM.
Reason: code looked messy
Tags for this Thread
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
|