Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Error :( 2

Status
Not open for further replies.

TudorSmith

Programmer
Jan 14, 2002
245
0
0
GB
Hi All

I have the following code calling a recordset from an SQL DB. I'm getting an error telling me the Object Variable is not set...and it's late...and my head is spinning [sadeyes]

Can anyone check my code and see what I'm missing on my oRS!

Code:
Set conn = New ADODB.Connection
strConnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MIS_Finances;Data Source=SQL01"
    conn.ConnectionString = strConnect
    
strSQL = ""
strSQL = strSQL & "SELECT Email FROM BBRIS_SupplierNotify "
    strSQL = strSQL & "WHERE SupplierID = " & Me.SupplierID & " "
    strSQL = strSQL & "AND ContractID = " & Me.ContractID & " "
    strSQL = strSQL & "AND ResourceTypeID = " & Me.RTypeID
    If conn.State = 0 Then
        conn.Open
    End If

    [COLOR=green]'Error happens on next line[/color]
    oRs.Open strSQL, conn, adOpenDynamic, adLockOptimistic
       oRs("Email") = Me.txtEmail
    oRs.Update

Any clues would be greatly appreciated...cuase I've burnt out !

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
Looks like you are missing an
Code:
Set oRS = New ADODB.RecordSet

line before the oRS.Open line.
 
IN red

Code:
Set conn = New ADODB.Connection
strConnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MIS_Finances;Data Source=SQL01"
    conn.ConnectionString = strConnect
    
strSQL = ""
strSQL = strSQL & "SELECT Email FROM BBRIS_SupplierNotify "
    strSQL = strSQL & "WHERE SupplierID = " & Me.SupplierID & " "
    strSQL = strSQL & "AND ContractID = " & Me.ContractID & " "
    strSQL = strSQL & "AND ResourceTypeID = " & Me.RTypeID
    If conn.State = 0 Then
        conn.Open
    End If
[red]set oRs = server.createobject("Adodb.recordset")[/red]
    'Error happens on next line
    oRs.Open strSQL, conn, adOpenDynamic, adLockOptimistic
       oRs("Email") = Me.txtEmail
    oRs.Update
 
Sorry I was thinking in ASP, use the new sytax or get rid of the server.

Rob
 
thanks Guys

I thought it might be obviious!

works great now :)

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top