how do I go about setting up, writing and executing an ado connecting to an access 97 database. The recordsourse being an sql statement used to populate a datalist?
Select ConnectionString and click the button that appears. Select the "Use connection string" option and click the build button. Browse to your database path and click the "Test Connection" button and make sure it succeeds. If not, it's a bad path or the drive the database is on is down (server?). Press Ok, then Apply on the origional form. Select the recordsourse tab, make sure the combo box says 1 - adCmdText, and type in your sql statement in the bottom textbox. That's hard coded, so if u need to change the sql statement at runtime, this is how I do it:
Const DBProvider as String = "Provider=Microsoft.Jet.
OLEDB.4.0;PersistSecurity Info=False"
Const DBPath as String = "C:\MyDatabasePath\MyDatabase.mdb"
dim strSQL as String
strSQL = "SELECT * FROM tblMyTable WHERE MyField = '" & txtCriteria.Text & "'"
Adodc1.Recordset.Close 'error here if already closed
Adodc1.Recordset.Open strSQL, DBProvider & DBPath
Set DataList1.DataSource = Adodc1
Hope that helps!
-Mike
DataSource=\\wcgoktulf153\tul1drftpln\MDB15sl\siteinfo.mdb; Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
Oops, messed up the connection string during copy/paste, here's what DBProvider should be, disregard the first statement after my name
Public Const DBProvider As String = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="
Then u can concantinate the DBPath to the end of this to complete ur connection string, and the path is flexible. If u have to move the location, u only have to change ur constant and design time connnections.
-Mike
Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.