473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Visual Basic 2005 Express Edition-Using SQL to fill text boxes

Hello,

I am currently using Visual Basic 2005 express edition with a MS Access database. I have made a "Contacts" Form, where the user will be able to enter a members surname and press an OK button, this then searches through the database and displays the results in the corresponding text boxes (ID, FirstName, LastName etc) of the searched member. I have used an SQL statement to search through the database, the problem I am having is filling the text boxes (ID, FirstName, LastName etc) with the correct member.

Below is my search code:

Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click

Dim inc As Integer
Dim maxrows As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\My Documents\Visual Studio 2005\Projects\BugReport\BugReport\Issues Database.MDB"

con.Open()

Dim str As String

str = "SELECT * FROM Contacts WHERE FirstName = '" & TextSearch.Text & "'"
da = New OleDb.OleDbDataAdapter(str, con)
da.Fill(ds, "Contacts")

con.Close()

ID.Text = ds.Tables("Contacts").Rows(0).Item(0)
FirstName.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(1) )
LastName.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(2) )
EmailAddress.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(3) )
Company.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(4) )
JobTitle.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(5) )
BusinessPhone.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(6) )
HomePhone.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(7) )
MobilePhone.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(8) )
FaxNumber.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(9) )
Address.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(10 ))
City.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(11 ))
StateProvince.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(12 ))
ZIPPostalCode.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(13 ))
CountryRegion.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(14 ))
WebPage.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(15 ))
Notes.Text = GetTextField(ds.Tables("Contacts").Rows(0).Item(16 ))

maxrows = ds.Tables("Contacts").Rows.Count
inc = 0

End Sub


Thanks in Advance
Sep 7 '07 #1
2 1552
I think the problem is within the text box related code rather than the SQL statment, as when I click OK the text boxes are always filled with the details of the first record.
Sep 7 '07 #2
Hi, just wondering if anyone could help me with the correct way to fill the textboxes.

Thanks
Sep 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: QLD_AU | last post by:
Has anyone see the following error ? VS 2005 Installs ok, however the SQL Mobile Edition (part of a full install) fails with the following error ? With Thanks Jason
4
by: Andrew Robinson | last post by:
My main dev machine has WinXp and VS2005 (pro). 1. I need to install VWD Express Edition so that I can do some instruction on this. Any issues with both on the same machine. Installation order?...
2
by: Progman | last post by:
I have Visual Studio 2005 Standard edition. Is ti the same thing as the Express edition or Standard is more?
3
by: Pitaridis Aristotelis | last post by:
Is there any way to create setup for a project made in Microsoft Visual Basic 2005 Express Edition
2
by: Hunk Gym | last post by:
VB.Net of Visual Studio.Net 2003 VS Visual Basic 2005 Express Edition Good Day! Would be appreciate if there is solution for the following problem: - In VB.Net of Visual Studio.Net 2003,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.