|
-
May 27th, 2005, 07:45 AM
#1
Thread Starter
Hyperactive Member
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:
Private Sub Contacts()
Dim sSQL As String
Dim strContacts As String
Set cnContacts = New ADODB.Connection 'we've declared it as a ADODB connection lets set it.
cnContacts.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\New Folder\Quote1.mdb" 'this is the connection string explained in the notes section.
cnContacts.Open
Set rsContacts = New ADODB.Recordset 'as we did with the connection
strContacts = frmCustomers.txtAddress1.Text
'Below is the SQL Statement to gather the correct information
'from tblContact and tblCustomer.
sSQL = "SELECT "
sSQL = sSQL & "Contact1 "
sSQL = sSQL & "FROM "
sSQL = sSQL & "tblContact "
sSQL = sSQL & "WHERE Address "
sSQL = sSQL & "= '" & strContacts & "' "
rsContacts.Open sSQL, cnContacts, adOpenDynamic, adLockOptimistic, adCmdText
Set DataGrid1.DataSource = rsContacts.DataSource
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|