Monday, December 17, 2007

How to create a table in database

How to create a table in database

S T E P - 1

- First, we need to connect to database.

Dim oConn

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

S T E P - 2

- We can use a SQL command to create a new table:

oConn.Execute "CREATE TABLE Member " & _ ' Create a table call "Member"

"(MemberName CHAR(20) NOT NULL, " & _ ' Create a field call "MemberName"

Password INTEGER NOT NULL);" 'Create a field call "Password"

S T E P - 3

- After using the connection, we will need to close it!

oConn.Close

Set oConn = Nothing

No comments: