|
-
Mar 12th, 2004, 01:49 PM
#1
Thread Starter
Frenzied Member
data reader question
if the query below returns zero rows, then shouldn't the objDR.read = false? The reason I ask this is becasue I know that no rows are being returned but it still goes into the Do while loop?
VB Code:
sqlCmd = "select employee_last_name,employee_first_name,employee_id from pcms.pcms_pcard where employee_work_unit='" & CmbWorkUnit.Text & "' and status_ind='A' order by employee_last_name"
Dim objCom As New OleDbCommand(sqlCmd, objCon)
Try
objCon.Open()
objDR = objCom.ExecuteReader
Do While objDR.Read = True
Me.CmbCards.Items.Add(Trim(objDR("employee_first_name")) & " " & (Trim(objDR("employee_last_name")) & " " & (Trim(objDR("employee_id")))))
Loop
objDR.Close()
Catch ex As Exception
MsgBox("Credit Card fill error: " & Err.Description)
Finally
objCon.Close()
End Try
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Mar 12th, 2004, 02:18 PM
#2
Frenzied Member
You might think so. Try using the HasRows property of the datareader if you're using framework 1.1
MSDN
I know an empty Access db still shows row 1, even though there's nothing in it. Maybe that's the problem.
-
Mar 12th, 2004, 03:20 PM
#3
Thread Starter
Frenzied Member
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Mar 12th, 2004, 03:25 PM
#4
Frenzied Member
Well, the link at MSDN has a section on Oracle, not sure if it'll help you. But one example there runs similar code to yours using HasRows
VB Code:
If myReader.HasRows Then
Do While myReader.Read()
Console.WriteLine(vbTab & "{0}" & vbTab & "{1}", myReader.GetInt32(0), myReader.GetString(1))
Loop
Else
Console.WriteLine("No rows returned.")
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|