CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2005
    Posts
    178

    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

  2. #2
    Join Date
    May 2005
    Posts
    178

    Re: create a recordset / database table

    anyone? plz...

  3. #3
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: create a recordset / database table

    Quote 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.

  4. #4
    Join Date
    May 2005
    Posts
    178

    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
  •  





Click Here to Expand Forum to Full Width

Featured