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
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim CandyShopPath = Application.StartupPath & "\SWEETSLIST.mdb"
- Dim SweetListSearch = ""
- Dim ConnectCandyShopDataBase As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & CandyShopPath
- Dim CandyShopCommand As OleDb.OleDbCommand
- Dim CandyShopDataReader As OleDb.OleDbDataReader
- Dim SWEETSQL = "SELECT Chocolate FROM CANDYSHOP WHERE ChocolateID = '" & ChocolateTextBox.Text '& "'AND SweetID =' " & SweetTextBox.Text & "'AND DrinksID='" & DrinksTextBox.Text & "'"
- ConnectCandyShopDataBase.Open() 'Open a database connection
- CandyShopCommand = New OleDb.OleDbCommand(SWEETSQL, ConnectCandyShopDataBase)
- *** CandyShopDataReader = CandyShopCommand.ExecuteReader
- If CandyShopDataReader.Read = True Then 'load information to relevant textboxes
- ChocolateTextBox.Text = SWEETSQL
- SweetTextBox.Text = SWEETSQL
- CrispsTextBox.Text = SWEETSQL
- DrinksTextBox.Text = SWEETSQL
- Else
- ChocolateTextBox.Text = "Error - Does Not Match code in Database"
- SweetTextBox.Text = "Error - Does Not Match code in Database"
- CrispsTextBox.Text = "Error - Does Not Match code in Database"
- DrinksTextBox.Text = "Error - Does Not Match code in Database"
- End If
- CandyShopDataReader.Close() 'close DataReader
- ConnectCandyShopDataBase.Close() 'close Database Connection
- End Sub
- End Class
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