SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 11th, 2001, 06:31 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Creating a database table using SQL CREATE TABLE

<i><b>Originally posted by : Aileen (aileenfarrell@hotmail.com)</b></i><br />Hi,<br />I am trying to create the tables in my database using ASP. I know the syntax of the CREATE TABLE and it works fine.<br /><br />Dim strSQL<br />strSQL = "CREATE TABLE test (name varchar(50),age int)"<br />conn.Execute strSQL<br /><br />However I want the user to enter the name of the table and the value will then be passed to this page. When I try to create the table using the value the user has entered I get a syntax error.<br /><br />Here is the code.<br /><br />Dim Connect, Info1, strconn, ModuleCode, rs<br />ModuleCode = request("ModuleCode")<br /><br />strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("students.mdb")<br />Set Connect = Server.CreateObject("ADODB.Connection") <br />Connect.open strconn<br />set rs = server.createobject("adodb.recordset")<br />Info1 = "CREATE TABLE" & ModuleCode & "(name varchar(50), age int)"<br />rs.open Info1, strconn<br />Connect.close<br />Set Connect = nothing<br /><br />The error is in the CREATE TABLE statement. <br />Anyone have any ideas?<br />

Reply With Quote
  #2  
Old June 25th, 2001, 04:39 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : </b></i><br /><br /><br /><br />------------<br />Aileen at 4/11/2001 4:31:26 AM<br /><br />Hi,<br />I am trying to create the tables in my database using ASP. I know the syntax of the CREATE TABLE and it works fine.<br /><br />Dim strSQL<br />strSQL = "CREATE TABLE test (name varchar(50),age int)"<br />conn.Execute strSQL<br /><br />However I want the user to enter the name of the table and the value will then be passed to this page. When I try to create the table using the value the user has entered I get a syntax error.<br /><br />Here is the code.<br /><br />Dim Connect, Info1, strconn, ModuleCode, rs<br />ModuleCode = request("ModuleCode")<br /><br />strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("students.mdb")<br />Set Connect = Server.CreateObject("ADODB.Connection") <br />Connect.open strconn<br />set rs = server.createobject("adodb.recordset")<br />Info1 = "CREATE TABLE" & ModuleCode & "(name varchar(50), age int)"<br />rs.open Info1, strconn<br />Connect.close<br />Set Connect = nothing<br /><br />The error is in the CREATE TABLE statement. <br />Anyone have any ideas?<br /><br />You will probably scream when you see what the problem is. You need white space between TABLE, ModuleCode, and the field list. Change it to:<br /><br />Info1 = "CREATE TABLE " & ModuleCode & " (name varchar(50), age int)"<br /><br />It works that way.<br /><br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Creating a database table using SQL CREATE TABLE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway