473,770 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

One SQL to poulate mulitple textboxes

1 New Member
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.
ChocloateTextBo x 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 1364
Atli
5,058 Recognized Expert Expert
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
11419
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 in.........." ??????????? T.i.a.
7
4100
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
1213
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. I really don't want the tabular look of the DataList. Is there a way of doing this in .NET? Thanks
11
3144
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 all the fields from two tables, each with about 20 fields. I then have a statistics form that has the query as its source and the form has 273 textboxes on, each with a calculation based on the underlying query values. The form looks like a...
2
1143
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 creation of form elements on the aspx page. I appreciate button postback events would normally post back to the main form the the page.
5
2317
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
2172
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" with the values to change the status to Pending, Accepted, Declined, Cancelled, Completed.
2
2644
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 working today) I have EasyPHP2.0b1 Apache/MySQL server installed on my Windows XP(SP2) machine. This runs Apache 2.2.3, MySQL 5.0.27 and PHP 5.2.0 I have a PHP code filled listbox, which allows multiple selections. Actual Values are "rcd_no, cn_no"...
6
1730
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 values during run time.
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.