Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
query1 = "select num,refno from porder where itemname='" & c & "' and po='" & d & "'"
        orc.Open()
        cmd = New OracleCommand(query1, orc)
        dr = cmd.ExecuteReader()
        a9 = dr.Item(0)
        e = dr.Item(1)


the error is

while it comes to a9 it shows "No data exists for the row or column."
Posted
Updated 17-Jul-11 22:42pm
v2

Put a debug point on the line that builds the query. Copy the temporary string built there and run it in a tool like SQL Management Studio against the appropriate database. If there are no results returned, you will know why you are getting this message.

Always use dr.HasRows in your code to confirm if the reader contains any rows or not.
 
Share this answer
 
Comments
Ra-one 18-Jul-11 4:52am    
Good detailing, my 5
It means the query did not return any rows. You should always check
IDataReader.HasRows
before accessing its members.

Also 'please solve the error', does not make a good title. Also make sure you show all relevant code, don't expect people to infer your code.
 
Share this answer
 
The query may not be selecting anything..Check the select query in your database...

Use a if condition..
 
Share this answer
 
v2
You have to dr.Read() before getting Datareader values.
While dr.Read()
    a9 = dr.Item(0)
    e = dr.Item(1)
End While
r.Close()


More details here[^].
 
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