0

i am trying to display a DB infos into a textbox.
This my code
sqlstr ="SELECT Description, Price FROM T_barcode WHERE Barcode ='" & Text1.Text & "'"
con.Execute sqlstr

Text2.Text = rec.Fields("Description")
Text3.Text = rec.Fields("price")

and iam recieving this "Item cannot be found in a collection corresponding to the requested name or ordinal"

barcode,description and price are my table fields.
can anybody tell me what's wrong in my code?

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by gsatya
0

i am trying to display a DB infos into a textbox.
This my code
sqlstr ="SELECT Description, Price FROM T_barcode WHERE Barcode ='" & Text1.Text & "'"
con.Execute sqlstr

Text2.Text = rec.Fields("Description")
Text3.Text = rec.Fields("price")

and iam recieving this "Item cannot be found in a collection corresponding to the requested name or ordinal"

barcode,description and price are my table fields.
can anybody tell me what's wrong in my code?

Hi,
I use to do this using recordset but I don't understand how you can display all the data of a field in a text box Normally such display will be done in combobox. I just give the snippet here try this.

dim cn as adodb.connection
dm rs as adodb.recordset

cn.open "Connection string" ' Substitute your connection string here
rs.open "SELECT Description, Price FROM T_barcode WHERE Barcode ='" & Text1.Text & "'",
con,adlockoptimistic 'Change the locktype as you wish

if not rs.eof then
rs.movefirst

do until rs.eof
combo1.additem = rs!description
combo2.additem = rs!price
loop
endif

Note: ensure that you have spelled your fields correctly.

0

Thanks for your help but i need to display it into a textbox not in combobox.
Even if it is in a combobox your code is not working check it well.
Thank you.

0

hi friends, I have to know how to read/ write in to the smart card. i am using mifare demo with VB6.0. i need to know the commands. Kindly respond me. Thanks. sanyak.

0

Have you displayed it in Text Box if so pls attach the snippet. Install msdn and use vb so that minor helps you may get from it.

Thanks
Satya. G

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.