Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command to create new Access DB

Status
Not open for further replies.

adrianjohnson

Programmer
May 16, 2002
145
GB
Hi,

I'm writing an application where I need to know the command (DOS) to create a new Access DB. Anyone have any ideas what it is please?

Thanks,

Adrian Johnson
 
I think you will have to copy a blank Access db with DOS. If this misses your point, perhaps you could explain a little more?
 
Basically, I've written an application in Java, where the user grabs some info from one database, and they need to then create a new database to put the results in.

Java doesn't have a command to create a new Access DB, so I'm after the Windows command (e.g. what you'd type in DOS to create one), and then my Java app would run that particular Windows command.

I've asked in the Java and Windows XP forums too, but all I need is the Windows command to create an Access DB.

Thanks,

Adrian
 
This is the vbscript to create mdb file and table. Modify the names/paths for your own setup:

' create a new mdb file
set cat = createobject("ADOX.Catalog")
cat.Create "provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=I:\afiles\test.mdb"
set conn = cat.ActiveConnection

' create a new table
strSQL = "CREATE TABLE tblTest " & vbCrLf & _
"( TestID AUTOINCREMENT " & vbCrLf & _
" CONSTRAINT pk PRIMARY KEY, " & vbCrLf & _
" Textfield VARCHAR(20) NOT NULL " & vbCrLf & _
" DEFAULT ""-""" & vbCrLf & _
")"


' Show SQL string
WScript.Echo strSQL


On Error Resume Next
conn.execute strSQL, dwRecordsAffected, adCmdText + adExecuteNoRecords
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top