Results 1 to 6 of 6

Thread: Adodb and datagrid

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Post Adodb and datagrid

    Hello, for some reason ever since I started changing from bound controls to code for ADO connections, simple things are becoming more complicated. I have a datagrid on a form, that I want to fill. I want it to fill from Quote1.mdb, tblContact.Contact1. But, I only want it to add contacts that match the displayed address in a textbox. This should be easy, I always get an error saying something isn't BookMarkable.
    Below, is the connection code:

    VB Code:
    1. Private Sub Contacts()
    2.  
    3. Dim sSQL As String
    4. Dim strContacts As String
    5.        
    6. Set cnContacts = New ADODB.Connection 'we've declared it as a ADODB connection lets set it.
    7.     cnContacts.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    8.     "Data Source= C:\New Folder\Quote1.mdb" 'this is the connection string explained in the notes section.
    9.     cnContacts.Open
    10. Set rsContacts = New ADODB.Recordset 'as we did with the connection
    11.    
    12. strContacts = frmCustomers.txtAddress1.Text
    13.  
    14.     'Below is the SQL Statement to gather the correct information
    15.     'from tblContact and tblCustomer.
    16.     sSQL = "SELECT "
    17.     sSQL = sSQL & "Contact1 "
    18.     sSQL = sSQL & "FROM  "
    19.     sSQL = sSQL & "tblContact "
    20.     sSQL = sSQL & "WHERE Address "
    21.     sSQL = sSQL & "= '" & strContacts & "' "
    22.  
    23.     rsContacts.Open sSQL, cnContacts, adOpenDynamic, adLockOptimistic, adCmdText
    24. Set DataGrid1.DataSource = rsContacts.DataSource
    25. End Sub

    Also, is datagrid the right control I should use if I also want to add data to the tbl by typing in the datagrid?
    Last edited by LostAngel; May 27th, 2005 at 09:48 AM.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

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