I can manually connect controls on a Form to an Access Database through ADO. Some authors say that it is better to do the connection through codes if your database is large.
I have tried to connect controls on a Visual Basic Form via ADO by codes many times and have never been able to.
Can any member help me, please?
Thanks in advance.
Akinyemi.
Hi,
Try using this code
Dim conn1 as String
conn1 = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="
conn1 = conn1 + Text1.Text 'Set Text1.text = double ticks (")
conn1 = conn1 + "DBQ="
conn1 = conn1 + databasefileactualpath
conn1 = conn1 + "yourdatabasename.mdb;"
conn1 = conn1 + "Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN="
conn1 = conn1 + databasefileactualpath
conn1 = conn1 + "createdsn file.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTime out=5;PWD=password(if exists input here);SafeTransactions=0;Threads=3;UID=admin;UserC ommitSync=Yes;"
conn1 = conn1 + Text1.Text 'Set Text1.text = double ticks (")
conn1 = conn1 + ";Initial Catalog="
conn1 = conn1 + databasefileactualpath
conn1 = conn1 + "yourdatabasename without file extension"
Adodc1.ConnectionString = conn1
Set the following properties in Adodc control
Command Type: 2 - adCmdTable
CursorType: 1- adOpenKeySet
Password: if password exists for the database, input here.
Regards,
Padhu