-
September 26th, 2005, 08:17 AM
#1
disconnected recordset
im trying to create a disconnected recordset to be the record source of a data control.
so i wrote-
Dim rs As New ADODB.Recordset
rs.ActiveConnection = Nothing
rs.CursorLocation = adUseClient
rs.LockType = adLockBatchOptimistic
rs.fields.Append "name", adBSTR, 30
rs.fields.Append "last", adBSTR, 30
rs.Open
rs.AddNew
rs.fields("name") = "x"
rs.fields("last") = "y"
Data1.RecordSource = rs
Data1.Refresh
but im getting the runtime error-> "type mismatch"
how can i do that? whats wrong?
thanks in advanced.
Last edited by ppl1; September 27th, 2005 at 02:03 AM.
Reason: a change
-
September 27th, 2005, 02:06 AM
#2
Re: create a recordset / database table
-
September 27th, 2005, 02:22 AM
#3
Re: create a recordset / database table
Originally Posted by ppl1
anyone? plz...
I would use a ADODC data Control instead of the Data Control. To get ADODC in your toolbox, right click on the Toolbox, select components and in the new dialog that comes up look for Microsoft ADO Data Control 6.0.
Also Data control that is present in the toolbox by default does not support dynamic recordsets. So thats the reason you are getting this error.
Try this instead
Code:
Dim rs As New ADODB.Recordset
rs.ActiveConnection = Nothing
rs.CursorLocation = adUseClient
rs.LockType = adLockBatchOptimistic
rs.Fields.Append "name", adBSTR, 30
rs.Fields.Append "last", adBSTR, 30
rs.Open
rs.AddNew
rs.Fields("name") = "x"
rs.Fields("last") = "y"
Set Adodc1.Recordset = rs
Debug.Print Adodc1.Recordset.Fields(0).Value
Debug.Print Adodc1.Recordset.Fields(1).Value
Debug.Print Adodc1.Recordset.Fields(0).Name
Debug.Print Adodc1.Recordset.Fields(1).Name
Debug.Print Adodc1.Recordset.RecordCount
ADODC1 is the Microsoft ADO Data Control which was selected from the Components dialog.
-
September 27th, 2005, 03:12 AM
#4
Re: create a recordset / database table
its working now
thanks for the help (again)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|