Hi can someone help me?
I'm using Access database and Microsoft VS2005 (VB)
I need to take data from 2 different tables in 1 database. But i can't seems to get it right!
I have:
- dbWarehouse.mdb
- tblReadDetails and tblStock
I need to use "Barcode" from tblReadDetails, compare it with "Barcode" in tblStock then retrieve all the column in tblStock and put it in a webpage.aspx list box.
I tried the following code...
cn.ConnectionString = strConn
cn.Open()
cmd =New OleDbCommand("SELECT tblStock.Barcode, tblStock.Item, tblStock.Dept, tblReadDetails.Barcode FROM tblStock JOIN tblReadDetils WHERE tblReadDetails.Barcode = tblStock.Barcode", cn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While dr.Read()
lstBarcode.Items.Add(dr2.Item("tblStock.Barcode"))
lstItem.Items.Add(dr2.Item("tblStock.Item"))
lstDept.Items.Add(dr2.Item("tblStock.Dept"))
EndWhile
but it prompt me the following error...
OleDbException was unhandled by user code
Syntax error in FROM clause
What's wrong with this code?
Regards and thanks!
Hi rinaxanir,
Try this:
SELECT tblStock.Barcode, tblStock.Item, tblStock.DeptFROM tblStockINNERJOIN tblReadDetailsON tblStock.Barcode = tblReadDetails.Barcode
Hope this helps,
Adam
|||Thanks Adam!
It's perfect!
Rina
No comments:
Post a Comment