i want to create a program that uses an access database, but i want to create the database (mdb file) all the tables and fields with code... is there a way to do it? is there an article or sample or somthing on how to do it?
| SitePoint Sponsor |
i want to create a program that uses an access database, but i want to create the database (mdb file) all the tables and fields with code... is there a way to do it? is there an article or sample or somthing on how to do it?





You can do this in Access with basic SQL statements like other databases, although, the exact syntax will vary from database to database.
http://msdn.microsoft.com/library/de...able___sql.asp
[QUOTE='westmich']You can do this in Access with basic SQL statements like other databases, although, the exact syntax will vary from database to database.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fox7help/html/lngcreate_table___sql.asp[/QUOTE]
im making the program in vb.net would it still work?
Westmich, the URL you quote is for FOXPro...
Load up Access, go to Help, then click your way through the tree to:
(that's the path in Access XP/2002 anyway)Code:Microsoft Jet SQL Reference -> Microsoft Jet SQL Reference -> Data Definition Language
There you will find the full syntax of statements such as CREATE TABLE, which will allow you to do what you have asked...
![]()
MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
thanks! I found the samples. I'm not sure I know enough about sql statements to understand it tho... I'm wondering if it might be easier for me to just create the table in access. I wanted to create it in code because I want to give the user some choice of what fields they want to use, so they can customize their program to thier needs. I created a few extra fields in an exzisting table called fldCustom1, fldCustom2 ... but it really dosen't give them the customize I want them to have.Originally Posted by M@rco
thanks for the help!

Why don't you go to aspin.com and get one of the table editors there? There's one from eDevNetworx (I think that's what it's called) and there's one from a guy here that did one. You should be able to find one that does what you need.





Not sure on the link - it was simply pointing to a create table SQL statement that I ran in Access so I know it works. In your code, you can have -
and so on...Code:SQL = " Create Table myTable ( myID INT Not Null, myField varchar(25) Nulll, )"
For actual SQL reference, start here http://www.w3schools.com/sql/default.asp
Bookmarks