ElvasLion
asked on
CREATE DATABASE with ADO
I again!
This time i need to know how can i create an access database trough vb code. I already know how to create the tables, indexes and all that but i need to know hoe to create the database itself and the odbc file (FileDsn).
Thanks in advance.
This time i need to know how can i create an access database trough vb code. I already know how to create the tables, indexes and all that but i need to know hoe to create the database itself and the odbc file (FileDsn).
Thanks in advance.
As for the file DSN, you can create one of those using Control Panel. For example in Windows 98 you choose Start-Settings-Control Panel-ODBC Data Sources. Then choose the File DSN tab.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
CJ S
The example is very interesting but that is using the DAO technology right. I want to use the ADO technology.
Thanks Anyway
CorporateRobot
I know how to create a FileDsn in windows i want to create it by code
Thanks to u2
dsa7
Your answer worked just fine but please answer me to the second part of the question and i will give you the points aswell a A grade.
Thanks
The example is very interesting but that is using the DAO technology right. I want to use the ADO technology.
Thanks Anyway
CorporateRobot
I know how to create a FileDsn in windows i want to create it by code
Thanks to u2
dsa7
Your answer worked just fine but please answer me to the second part of the question and i will give you the points aswell a A grade.
Thanks
You do not need a FileDSN. After you create the database you can open the access table using the code below. If you table name has a space in it make sure you put brackets around it in your sql statement like
SELECT * FROM [MY TABLE]
Also, check out the following link
http://msdn.microsoft.com/library/psdk/dasdk/pg_i8kry.htm
If you are going to be using ADO a lot you might want to check out the book ADO 2.6: Programmer's Reference from Wrox publisher.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
ConnString = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\TEMP\MYDATABASE. mdb"
cnn.Open "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\TEMP\MYDATABASE. mdb;Persis t Security Info=False"
rs.Open "SELECT * FROM MYTABLE", cnn, adOpenKeyset, adLockOptimistic
SELECT * FROM [MY TABLE]
Also, check out the following link
http://msdn.microsoft.com/library/psdk/dasdk/pg_i8kry.htm
If you are going to be using ADO a lot you might want to check out the book ADO 2.6: Programmer's Reference from Wrox publisher.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
ConnString = "Provider=Microsoft.Jet.OL
cnn.Open "Provider=Microsoft.Jet.OL
rs.Open "SELECT * FROM MYTABLE", cnn, adOpenKeyset, adLockOptimistic
If you really need to create a FileDSN check out the following link which shows you how.
http://www.vb2themax.com/Item.asp?PageID=TipBank&Cat=1000&ID=235
http://www.vb2themax.com/Item.asp?PageID=TipBank&Cat=1000&ID=235
ASKER
Thanks again for your answer i'm going to check out the links but even if i can't find what i need your answer has already been excellent for 50 points.
thanks again.
thanks again.
http://www.vbsquare.com/tips/tip428.html
Regards,
CJ