Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Creating tables into Access using ASP cod
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Creating tables into Access using ASP cod

 Post Reply Post Reply
Author
bcorso View Drop Down
Newbie
Newbie


Joined: 14 September 2002
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote bcorso Quote  Post ReplyReply Direct Link To This Post Topic: Creating tables into Access using ASP cod
    Posted: 01 January 2005 at 9:19pm
I am trying to have asp code create a new column automatically into an Access database table.  What would be the correct wording to do this? 
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 01 January 2005 at 11:16pm
Just execute a standard query with a syntax i.e.

Alter Table tablename add column NewColumnname text(250) NOT NULL
for a new column with the name NewColumnname of the type text with a max lenght of 250 and required (not null). Just alter the syntax to reflect your needs. Having that programatically I'd assume that the column name is dynamic so it'll be something like

<%
Dim strSQL as String
strSQL = "Alter Table tablename add column " & varNewColumn & " text(250) NOT NULL"
%>


Edited by michael - 01 January 2005 at 11:16pm
Back to Top
bcorso View Drop Down
Newbie
Newbie


Joined: 14 September 2002
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote bcorso Quote  Post ReplyReply Direct Link To This Post Posted: 01 January 2005 at 11:39pm
Hi Michael,
This is the way it was written originally, but it doesn't work:
Would this be correct?
 
Thank you!!!

re.Open "Alter Table in member Add Column " & PCName & " varchar(50) default None",conn2

sql = "Update member Set " & PCName & " = 'None'"

 re.Open sql,Conn2
  Conn2.Close


Edited by bcorso - 02 January 2005 at 12:52am
Back to Top
bcorso View Drop Down
Newbie
Newbie


Joined: 14 September 2002
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote bcorso Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2005 at 12:47am
 This is the error it produces.  Quite frustrating :(

Microsoft JET Database Engine error '80040e14'

Syntax error in field definition.

Back to Top
bcorso View Drop Down
Newbie
Newbie


Joined: 14 September 2002
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote bcorso Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2005 at 11:49am
Just wanted to post an update, hopefully this will help others.  I ended up using the code I had, apparently it is correct, but while I was entering the data for the new table, I was using spaces in my text.  I guess it does not like spaces as when I removed them and made it all one long word, it took it fine and created the table.

This is probably common knowledge, but I'm still learning! Confused
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.