If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Error while opeing up a recordset in ado 2.5

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-04, 12:21
zap123 zap123 is offline
Registered User
 
Join Date: Mar 2004
Posts: 1
Question Error while opeing up a recordset in ado 2.5

I am opening up a recordset in ado2.6 I keep getting this error 2147217908","Command text was not set for the command object.","Microsoft OLE DB Provider for ODBC Drivers. Can anyone help? I know the sql statement works.

Here is my code
'Dimmensions
Dim I As Integer
Dim conSQL As ADODB.Connection
Dim rsSQL As ADODB.Recordset
Dim strSQL As String
Dim strDateFrom As String
Dim strDateTo As String
Dim strLineNumber As String
Dim blnStartup As Boolean
Dim strDefect(100, 1) As String

On Error GoTo errhandle:

strDateFrom = Sheets("start(1)").txtFirstdate.Text & Space(1) & "00:00:01 AM'"
strDateTo = Sheets("start(1)").txtSecondDate.Text & Space(1) & "11:59:59 PM'"
strLineNumber = Sheets("start(1)").Range("c5").Value
'Builds the sql Statement
strbuild = "select " & _
" DATEDIFF(MINUTE,startdatetime,enddatetime) as Timeused " & _
" ,tblexistingrollcut.rollnumber, " & _
" tblexistingrollcut.cutname,dispositioncode,rollcut defect from " & _
" tblroll,tblexistingrollcut left outer join tblrollcutdefect " & _
" on tblexistingrollcut.rollnumber = tblrollcutdefect.rollnumber AND " & _
" tblexistingrollcut.cutname = tblrollcutdefect.cutname " & _
" where tblroll.rollnumber = tblexistingrollcut.rollnumber AND " & _
" linenumber = '" & strLineNumber & "' and " & _
" startdatetime > '" & strDateFrom & " AND " & _
" ENDDATETIME < '" & strDateTo & _
" order by rollnumber"

MsgBox strbuild
''''''''''''''''''''''''''''''''''''''''''''''''''
'Creates the connection to the database
Set conSQL = New ADODB.Connection
Set rsSQL = New ADODB.Recordset
''''''''''''''''''Connecting to Production'''''''''''
If conSQL.State = adStateOpen Then
conSQL.Close
End If
Application.StatusBar = "(Connecting) to Production server"
'on the fly connection
conSQL.Open "Driver={sql server};server=production;database=dbsims;UID=test ;pwd=test"

'''''''Pulling Defect % ''''''''''''''''''''''''''''''
Application.StatusBar = "(Connected Pulling Defect % from production server"
rsSQL.Open strSQL, conSQL, adOpenForwardOnly, adLockReadOnly <--- This where it errors on..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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