Print Page | Close Window

Creating tables into Access using ASP cod

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13175
Printed Date: 30 March 2026 at 11:05pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Creating tables into Access using ASP cod
Posted By: bcorso
Subject: Creating tables into Access using ASP cod
Date 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? 



Replies:
Posted By: michael
Date 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"
%>


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: bcorso
Date 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


Posted By: bcorso
Date 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.



Posted By: bcorso
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net