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?

Recommended Answers

All 5 Replies

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.

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.

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.

I was able to resolve it myself.
Thank all

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.