-
August 1st, 2011, 07:19 AM
#1
Database Frontend
Hi, Im trying to develop a frontend for a database project I have been working on, I am using a combobox to select a meal_name and need the primary key to update another table for orders, How can I retreive the primary key using the meal name selected.
below is the code I am using to add meal names to the combobox
Private Sub ComboBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.MouseEnter
Dim myRow As DataRow
Dim CmdStr As String
Dim myDataSet As DataSet = New DataSet()
Dim ConStr As String = "server = USER-PC\SQLEXPRESS ; Database = happy_meals ; integrated security=true"
CmdStr = "SELECT Meal_Name FROM Meal"
Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(CmdStr, ConStr)
myDataAdapter.Fill(myDataSet, "Meal")
ComboBox1.Items.Clear()
With myDataSet
For Each myRow In myDataSet.Tables("Meal").Rows
ComboBox1.Items.Add(myRow("Meal_Name"))
Next
End With
End Sub
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
|