Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
I am trying to retrieve data from two tables to fill the textboxex when I'm click the Button Print but I got an error saying: Column 'UID' in where clause is ambiguous. I have two tables named tableProducts with Columns ProductID, ProductName, and ProductPrice AND tableQuantity with columns QuantityID and AvailableQuantity. Please help me.

Here are my codes.

SqlClientConn.Open()
        Dim SQLString As String = "SELECT ProductName,ProductPrice FROM tableProducts INNER JOIN tableQuantity ON tableProducts.ProductID = tableQuantity.QuantityID WHERE ProductID= '" & txtid.Text & "'"
        Dim mySqlDataAdapter As MySql.Data.MySqlClient.MySqlDataAdapter = New MySql.Data.MySqlClient.MySqlDataAdapter(SQLString, SqlClientConn)
        Dim ds As New DataSet
        mySqlDataAdapter.Fill(ds)
        If ds.Tables("tableProducts").Rows.Count > 0 Then
            txtname.Text = ds.Tables("ProductName").Rows(0).Item(0).ToString()
            txtprice.Text = ds.Tables("ProductPrice").Rows(0).Item(1).ToString()
            txtquantity.Text = ds.Tables("AvailableQuantity").Rows(0).Item(2).ToString()
           
        End If
        SqlClientConn.Close()
..
Posted

1 solution

You have two tables named
tableProducts with Columns ProductID, ProductName, and ProductPrice AND tableQuantity with columns QuantityID and AvailableQuantity. Please help me.

Question No . 1 You are selecting both columns from tableProducts then why you are running join query or your query incomplete .

Ok
following is the structure of query Please try


SQL
SELECT P.ProductName
,P.ProductPrice 
FROM tableProducts  P
INNER JOIN tableQuantity Q ON (P.ProductID = Q.QuantityID) 
WHERE P.ProductID=  txtid.Text 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900