2

again i came for a problem. Please help me to do this. I was tried to get quantity from db make use of the selection in list box. I got answered with listbox1. If i selected the item in listbox1 the quantity would appear in textbox1. But in this same code will not work for listbox2 with textbox4.. Here i given the code...

 $Con.open()
 $Dim cd as new oledb.oledbcommand("Select Quantity from tlist where tool_name"& "'"listbox2.selecteditem & "'" & "", con)
 $dim rs as oledb.oledbdatareader
 $do while rs.read
 $textbox4.text=(rs("Quantity))
 $loop
 $con.close

Here i got the error as "Conversion from type DBNull to type string is not valid" Plz let me know what will i do.??

1 Answer 1

2

There are a few issues.

  1. Your query is a bit off. It currently reads Select Quantity from tlist where tool_name'valueOfListbox2'". It should probably read Select Quantity from tlist where tool_name = 'valueOfListbox2'.
  2. Your getting a null value back and are not checking for a null return before writing the value out, hence the error. You can use the following IF statement to verify your value is not null:

    If NOT IsDbNull(rs("Quantity")) Then

  3. Also, you're missing a double quote around "Quantity".

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.