473,405 Members | 2,287 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,405 software developers and data experts.

One SQL to poulate mulitple textboxes

Hi All.

I am new to this forum... Don't know how to start but here it goes....


I am writing in VB.net a program with one form, yet mulitple textboxes.

the data appears in each text box as A1, A2, A3, A4, A5

The database CANDYSHOP has a table CANDYSHOP with each column as

ChocolateID Chocolate SweetID Sweet DrinksID Drinks
A1 snikers B1 jelly babies C1 pepsi
A2 mars B2 wine gums C2 sprite
A3 milkyway B3 polo C3 fanta etc.....

there are no more than 20 rows


My code is
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3.         Dim CandyShopPath = Application.StartupPath & "\SWEETSLIST.mdb"
  4.         Dim SweetListSearch = ""
  5.         Dim ConnectCandyShopDataBase As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & CandyShopPath
  6.         Dim CandyShopCommand As OleDb.OleDbCommand
  7.         Dim CandyShopDataReader As OleDb.OleDbDataReader
  8.  
  9.         Dim SWEETSQL = "SELECT Chocolate FROM CANDYSHOP WHERE ChocolateID = '" & ChocolateTextBox.Text '& "'AND SweetID =' " & SweetTextBox.Text & "'AND DrinksID='" & DrinksTextBox.Text & "'"
  10.  
  11.         ConnectCandyShopDataBase.Open()                       'Open a database connection
  12.         CandyShopCommand = New OleDb.OleDbCommand(SWEETSQL, ConnectCandyShopDataBase)
  13.  
  14.        *** CandyShopDataReader = CandyShopCommand.ExecuteReader 
  15.  
  16.         If CandyShopDataReader.Read = True Then          'load information to relevant textboxes
  17.             ChocolateTextBox.Text = SWEETSQL
  18.             SweetTextBox.Text = SWEETSQL
  19.             CrispsTextBox.Text = SWEETSQL
  20.             DrinksTextBox.Text = SWEETSQL
  21.  
  22.         Else
  23.             ChocolateTextBox.Text = "Error - Does Not Match code in Database"
  24.             SweetTextBox.Text = "Error - Does Not Match code in Database"
  25.             CrispsTextBox.Text = "Error - Does Not Match code in Database"
  26.             DrinksTextBox.Text = "Error - Does Not Match code in Database"
  27.  
  28.     End If
  29.  
  30.         CandyShopDataReader.Close()                     'close DataReader
  31.         ConnectCandyShopDataBase.Close()                      'close Database Connection
  32.  
  33.        End Sub
  34.  
  35. End Class
  36.  
Q. How would i display the corrseponding data in each textbox.
ChocloateTextBox is poulates with the value of A1, which in the databse is Snickers.
Currently it displays A1, not Snickers.

What steps do i need to take or what code is required to poulate the textbox with the product not the ID.

i think i need DataAdapter, but unsure?



Any help, answers, examples or tips would be much useful.

Many Thanks
Sep 26 '08 #1
1 1333
Atli
5,058 Expert 4TB
Hi, and welcome to Bytes!

This question seems to be much more about VB.Net than SQL.
I'm not even sure the database you are using is MySQL.

So, I am going to move this over to the .Net forum. I'm sure the experts there can help you more than we here at the MySQL forum.

Also, please use [code] tags when posting code examples.

Thank you.
Moderator
Sep 26 '08 #2

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

Similar topics

4
by: T. Wintershoven | last post by:
Hello, I have a few textboxes placed on a SSTab control devided over 3 tabs Is there a way to clear all textboxes in one time in stead of one by one. Someone told me "Use for each item...
7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
3
by: Robert | last post by:
Developing a form that has multiple controls; TextBoxes, RadioButtons, CheckBoxes, etc. I want to dynamically populate all the controls from the database and scroll through the data row by row. ...
11
by: ian.davies52 | last post by:
Is there anything I can do about the apparent limit on the number of textboxes that have calculations as their control source on a form or report in ms-access? I have a query that pulls together...
2
by: Martin | last post by:
Hi, I want mulitple html forms on one ASP.Net page. I guess it's invalid HTML to nest form elements, which is okay for me. My concern is that ASP.Net will not work well if I override the...
5
by: Dave H | last post by:
I have an asp:listbox, allowing multiple selections, is there a quick check to see if there's more than one selected, or do I need to go through the whole list? Thanks, Dave
14
by: bcap | last post by:
Hello, I really would apprciate help! =) What I want to do is be able to change the status of mulitple records using a drop down and a checkbox. I have a drop down called "ChangeStatus"...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
6
by: awhan.iitk | last post by:
I have a set of variables that I want to share across mulitple c++ files. I was using the extern method so far. Is there any other way to do the same. The variables are not constants and I get the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.