Forums
This topic is locked
Create Table on Ms Access
Posted 22 years ago
1
has voted
22 years ago agoes Setiawan posted:
I've got this code at a site, but doesn't work ...<%
Set adConn = Server.CreateObject("ADODB.Connection"

Set adRS = Server.CreateObject("ADODB.RecordSet"

'be sure to change the path to your database on the next line
adPath = "E:/the/path/to/your/database.mdb"
adConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & adPath & ";"
'below where it says "newtbl" this will be the name of the table
'below where it says "Name", "Email", "Comments", "Region", these are the fields
adSQL = "CREATE TABLE newtbl (Name text (50), Email text (75), Comments text (255), Region text (50))"
adConn.Execute adSQL
adConn.Close
Set adConn = Nothing
%>
Help Me plz
Replies
Replied 22 years ago
22 years ago Andrew Watson replied:
<pre id=code><font face=courier size=2 id=code>
<%
set conn = Server.CreateObject("ADODB.Connection"
conn.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\projects\testsite\data\test.mdb"
Dim strSQL
strSQL = "CREATE TABLE test (name varchar(50), age int)"
conn.Execute strSQL
%>
This creates a table succesfully, just tweak it to suit your needs....
Cheers
Leed
</font id=code></pre id=code>
:: Son, im Thirty.... ::
<%
set conn = Server.CreateObject("ADODB.Connection"

conn.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\projects\testsite\data\test.mdb"

Dim strSQL
strSQL = "CREATE TABLE test (name varchar(50), age int)"
conn.Execute strSQL
%>
This creates a table succesfully, just tweak it to suit your needs....
Cheers
Leed
</font id=code></pre id=code>
:: Son, im Thirty.... ::
Replied 22 years ago
22 years ago agoes Setiawan replied:
Look Great,
Many Thanks ...
Many Thanks ...
Replied 22 years ago
22 years ago agoes Setiawan replied:
Now I want to set ID with int auto number and as primary key with code below :
But still error ...
<%
set conn = Server.CreateObject("ADODB.Connection"
conn.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Com Agoes\DOKclick\DiaryArt\db\db1.mdb"
Dim strSQL
strSQL = "CREATE TABLE test (ID int(11) PRI auto_incresement, name varchar(50), age int)"
conn.Execute strSQL
%>
But still error ...
<%
set conn = Server.CreateObject("ADODB.Connection"

conn.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Com Agoes\DOKclick\DiaryArt\db\db1.mdb"

Dim strSQL
strSQL = "CREATE TABLE test (ID int(11) PRI auto_incresement, name varchar(50), age int)"
conn.Execute strSQL
%>
Replied 22 years ago
22 years ago agoes Setiawan replied:
I've fix it my self...
Thank you
Thank you