[AccessD] SPAM-LOW: Re: Binding forms and controls directly to SQL Server

jwcolby jwcolby at colbyconsulting.com
Tue Mar 23 14:31:35 CDT 2010


BTW this came from here:

http://support.microsoft.com/kb/281998

John W. Colby
www.ColbyConsulting.com


jwcolby wrote:
> OK, I got it working using the ADO recordset thing.  Basically I just do the typical ADO recordset:
> 
> Private Function GetADORst(strsql)
>     Dim cn As ADODB.Connection
>     Dim rs As ADODB.Recordset
> 
>     'Create a new ADO Connection object
> On Error GoTo Err_GetADORst
> 
>     Set cn = New ADODB.Connection
> 
>     'Use the Access 10 and SQL Server OLEDB providers to
>     'open the Connection
>     'You will need to replace MySQLServer with the name
>     'of a valid SQL Server
>     With cn
>        .Provider = "Microsoft.Access.OLEDB.10.0"
>        .Properties("Data Provider").Value = "SQLOLEDB"
>        .Properties("Data Source").Value = "M90"
>        .Properties("Integrated Security").Value = "SSPI"
> '      .Properties("User ID").Value = "sa"
> '      .Properties("Password").Value = ""
>        .Properties("Initial Catalog").Value = "C2DbBilling"
>        .Open
>     End With
> 
> Then open the recordset
> 
>     'Create an instance of the ADO Recordset class, and
>     'set its properties
>     Set rs = New ADODB.Recordset
>     With rs
>        Set .ActiveConnection = cn
> '      .Source = "SELECT * FROM tblTime"
>        .Source = strsql
>        .LockType = adLockOptimistic
>        .CursorType = adOpenKeyset
>        .Open
>     End With
> 
> then assign that as the recordset.
> 
>     Set Me.Recordset = rs
>     Set rs = Nothing
>     Set cn = Nothing
> 
> Voila, editable form.  And FAST!
> 
> John W. Colby
> www.ColbyConsulting.com
> 
> 
> jwcolby wrote:
>> I seem to remember Charlotte saying that you could open an ADO RECORDSET and bind the form to that 
>> recordset to make the form read/write.
>>
>> John W. Colby
>> www.ColbyConsulting.com
> 



More information about the AccessD mailing list