Forums

ASP

This topic is locked

Create Table on Ms Access

Posted 15 May 2002 09:20:40
1
has voted
15 May 2002 09:20:40 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 15 May 2002 10:24:52
15 May 2002 10:24:52 Andrew Watson replied:
<pre id=code><font face=courier size=2 id=code>
&lt;%
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
%&gt;

This creates a table succesfully, just tweak it to suit your needs....

Cheers
Leed
</font id=code></pre id=code>

:: Son, im Thirty.... ::
Replied 15 May 2002 11:01:45
15 May 2002 11:01:45 agoes Setiawan replied:
Look Great,

Many Thanks ...

Replied 16 May 2002 07:08:25
16 May 2002 07:08:25 agoes Setiawan replied:
Now I want to set ID with int auto number and as primary key with code below :
But still error ...

&lt;%
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
%&gt;

Replied 17 May 2002 04:13:51
17 May 2002 04:13:51 agoes Setiawan replied:
I've fix it my self...

Thank you

Reply to this topic