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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind ADO RS to continuous form

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
Using SQL server 2000 and Access 2000.

I've read and am still unable to update my form. Can anyone offer an suggestions.

Code:
Function OpenConnection()
Dim constr As String


'Dim conn As ADODB.Connection
On Error GoTo ERROR_HANDLER_CON
'Set conn = New ADODB.Connection

If conn Is Nothing Then
    Set conn = New ADODB.Connection
End If
'*******************
With conn
.Provider = "MSDataShape"
         
      'The code below uses a sample server name, user ID, and password.
      'Be sure to use your actual server name, user ID, and password.
      .ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA " _
         & "SOURCE=STAT1;Initial Catalog=SCHED;Trusted_Connection=Yes"
      .CursorLocation = adUseServer
      .Open
   End With
Exit Function

And in my form load. I have also tried form open.

Code:
Dim rsTemp As ADODB.Recordset

Set rsTemp = New ADODB.Recordset

With New ADODB.Command
    .ActiveConnection = conn
    .CommandText = "USP_TempRS"
    .CommandType = adCmdStoredProc
    

    .Parameters.Append .CreateParameter("@USERNAME", adChar, , 8, Environ("USERNAME"))
    Set rsTemp = .Execute

End With

Set Me.Recordset = rsTemp
 
'conn.Close
Forms!FRMMAIN_SQL.Visible = True
DoCmd.Maximize
End Sub
 
Hey Remou,

Thanks for the reply. I tried adding the cursor type and still can not update my form. Do you have anymore suggestions please.

Code:
Dim rsTemp As ADODB.Recordset

Set rsTemp = New ADODB.Recordset

With New ADODB.Command
    .ActiveConnection = conn
    .CommandText = "USP_TempRS"
    .CommandType = adCmdStoredProc


    .Parameters.Append .CreateParameter("@USERNAME", adChar, , 8, Environ("USERNAME"))
    [red]rsTemp.CursorType = adOpenKeyset[/red]
    Set rsTemp = .Execute()

End With
 
Seems no matter what I do I get back a static cursor as shown in the immediate window.

Code:
?rstemp.CursorType 
 3
 
I've found that if I don't use a stored procedure I can get an updateable RS returned.

Code:
rsTemp.Open "Select * from Scheduler_form", conn, adOpenKeyset, adLockOptimistic, adCmdText

Is there anyway to do it with the stored procedure?
 
PHV
When testing, I found that using a stored procedure to create the recordset gives:

Error 7965 "The object you entered is not a valid recordset property"

When trying to bind the recordset (Set Me.Recordset = rs)

 
The thing is, that link refers to binding a recordset based on sql text, not a recordset based on a command object, which would typically be used with a stored parameter query.

 
Oh, I see.
Sorry I can't test anything as I don't use MS-SQL at all.
 
remou said:
When testing, I found that using a stored procedure to create the recordset gives:

Error 7965 "The object you entered is not a valid recordset property"

When trying to bind the recordset (Set Me.Recordset = rs)

I got the same error until I changed the connection string to my SQL DB to use a Provider of MSDATASHAPE as I show in my first post. I found that reference here
I have the form bound to the recordset now and I'll post the code when I get back to work tomorrow as I have encounterd another challenge.
 
What does the stored proc look like?
Stored procs can return data sets, parameters or nothing.
If you post it, we may find out what's happening.


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top