LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Recordset keeps returning EOF and shouldn't be.


Hello everyone,

The following code should grab policy number from cell B from the
activeworksheet, then go through a recordset (that is a SQL table) to
find that recordset.

However, the following code is always returning EOF even though I am
hardcoding a policy number that I know exists in the table.


Here it is:

Dim oConn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
Set rng = Cells(Rows.Count, 1).End(xlUp)

(connection properties changed for privacy)

oConn = "Driver={SQL Server};" & _
"Server=OurSQLServer;" & _
"Database=OverDatabase;" & _
"Uid=joesmoe;" & _
"Pwd="

oConn.Open

'rst.Open "Select polnum, EntryDate From tblOurTable", oConn,
adOpenStatic

For i = rng.Row To 3 Step -1
'strPolicyNumber = Cells(i, "B").Value


strPolicyNumber = "Z9999858" <--- This policy number is there, but
recordset returns EOF


rst.Open "Select polnum, F_EntryDate From ipdSysUser.tblQueueLoc_NBPROD
WHERE polnum = ' " & strPolicyNumber & "'", oConn, adOpenStatic


If rst.EOF Then GoTo NextPolicy:
Debug.Print rst("polnum")

NextPolicy:
rst.Close
Next i

Thanks,
Brian

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need ADO Recordset Help Mr B[_2_] Excel Programming 9 April 21st 06 04:51 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Returning the Number of Rows in a Recordset Alex[_14_] Excel Programming 2 November 1st 03 11:14 AM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"