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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Database

Status
Not open for further replies.

WoodyRoundUp

Programmer
Feb 28, 2001
187
AU
Hi there.
May I know how can I create a Database with coding?
Please guide me through.
Coz I am new in programming.
Thanks.

Budi
 
What kind of database? Can you give any more details? If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]

[cheers]
 
hi there.
what i want to create is a simple database with one table.
the creation of the table is not a problem. i can deal with that. i just dunno how to create a mdb file (which does not exist before), by using coding.
i really need help on this.
thanks for your help.

budi
 
Here is some code to get you started

'Add a reference to ADO Ext 2.xx for DLL and Security
Private Sub cmdCreateDB_Click()
Dim cat As New ADOX.Catalog
Dim tbl As New Table
Dim sConnection As String

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\newDBName.mdb"
cat.Create sConnection
cat.ActiveConnection = sConnection
tbl.Name = "newTableName"
tbl.Columns.Append "newColumn1Name", adInteger
tbl.Columns.Append "newColumn2Name", adVarWChar, 25
cat.Tables.Append tbl

Set tbl = Nothing
Set cat = Nothing
End Sub

Let me know if it helps. [flip] If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]

[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top