•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 374,153 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,449 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 1050 | Replies: 8
![]() |
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 1
Solved Threads: 0
Hey guys!
I was wondering if anyone could help me. I am a student on my work placement year and I am developing a web based database. I have been asked to design it so users can if need be add a new table to the database or add a new column to an existing table. I have never done this before, how would I go about doing this?? I was thinking that I would have to use some kind of stored procedure and a form the users could fill in? but I have no idea where to start.
I am using Dreamweaver MX and Access, I will be using SQL Server but I am using Access at the minute to create a practice dummy site.
Thanks!
Any ideas would be greatly appreciated!
GLT
(I have asked this same question in the ASP forum but getting no responses)
I was wondering if anyone could help me. I am a student on my work placement year and I am developing a web based database. I have been asked to design it so users can if need be add a new table to the database or add a new column to an existing table. I have never done this before, how would I go about doing this?? I was thinking that I would have to use some kind of stored procedure and a form the users could fill in? but I have no idea where to start.
I am using Dreamweaver MX and Access, I will be using SQL Server but I am using Access at the minute to create a practice dummy site.
Thanks!
Any ideas would be greatly appreciated!
GLT
(I have asked this same question in the ASP forum but getting no responses)
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,907
Reputation:
Rep Power: 9
Solved Threads: 216
Create table
The problem that you facing here is
Remove column
sql Syntax (Toggle Plain Text)
CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, )
- Table is always same so you just run your prepared statement
- Tables can be different, you must provide a way/interface through which user can declare table name, column types, you just add the magic words CREATE TABLE and then execute it
sql Syntax (Toggle Plain Text)
ALTER TABLE table_name ADD column_name datatype
sql Syntax (Toggle Plain Text)
ALTER TABLE table_name DROP COLUMN column_name
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 1
Solved Threads: 0
Hi thanks for replying!
I do know the SQL for creating and altering tables but I was wondering if anyone had any idea how I would get information from a form or something in dreamweaver to then create the table. The users dont know much about programming or database's so I was hoping to make a simple form or something for them to fill out. Is this possible??
ideas would be greatly appreciated!
Thanks!
GLT
I do know the SQL for creating and altering tables but I was wondering if anyone had any idea how I would get information from a form or something in dreamweaver to then create the table. The users dont know much about programming or database's so I was hoping to make a simple form or something for them to fill out. Is this possible??
ideas would be greatly appreciated!
Thanks!
GLT
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,907
Reputation:
Rep Power: 9
Solved Threads: 216
Ofcourse it is possible, you just have to tell us which technology you plannig to use. PHP/JSP/ASP/ Ruby on Rails? Also so proper scenario to explain situation would help.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 1
Solved Threads: 0
Thank you,
I'm using ASP with SQL Server 2005. The web based database that I am developing will hold details of the companies products and customers, their orders and enquiries. I have developed a database structure for this but I am only here for a few more months (I am a student on placement), the company want me to include a way so they can add new columns to existing tables if they need to store extra info and so they can add new tables if need be.
GLT
I'm using ASP with SQL Server 2005. The web based database that I am developing will hold details of the companies products and customers, their orders and enquiries. I have developed a database structure for this but I am only here for a few more months (I am a student on placement), the company want me to include a way so they can add new columns to existing tables if they need to store extra info and so they can add new tables if need be.
GLT
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,907
Reputation:
Rep Power: 9
Solved Threads: 216
For ASP development I would recommend to use Visual Studio, that you can get for free from Microsoft website .
Back to your project...
You been given task that is nearly extensive as final year project. I would recommend you have look on few SQL Browser interfaces such as phpMyadmin, MySQL Query Browser, SQL Server Management Studio Express or any other so you get idea what you need to provide for user.
Do not go extensive on it, given them just basic options so they do not mess up anything. You should just offer option to select in which database new table should be created, text field for table name, then text fields for column names (make sure that table and variables names appropriate not special characters such as comas, dots, slash etc), drop down options for variable types (just work out what are most common variable types they use, you do not need all of them) and possible initial values (for this I would recommend you have good look at phpMyadmin).
Adding new collumn approach is somewhat similar to creating new table, but this time you have to select database and table.
Back to your project...
You been given task that is nearly extensive as final year project. I would recommend you have look on few SQL Browser interfaces such as phpMyadmin, MySQL Query Browser, SQL Server Management Studio Express or any other so you get idea what you need to provide for user.
Do not go extensive on it, given them just basic options so they do not mess up anything. You should just offer option to select in which database new table should be created, text field for table name, then text fields for column names (make sure that table and variables names appropriate not special characters such as comas, dots, slash etc), drop down options for variable types (just work out what are most common variable types they use, you do not need all of them) and possible initial values (for this I would recommend you have good look at phpMyadmin).
Adding new collumn approach is somewhat similar to creating new table, but this time you have to select database and table.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 1
Solved Threads: 0
Hi, Thanks for you help!
This is what ive got so far... it may be completely wrong but am I on the right lines??
stored procedure:-
asp:-
SQL Server doesnt like the @ symbol but I dont know how else to do this.
the asp code - the select text boxes are for the user to input datatype.
Thanks for all you help! all ideas greatly appreciated!
GLT
This is what ive got so far... it may be completely wrong but am I on the right lines??
stored procedure:-
CREATE PROCEDURE sp_createtable AS CREATE TABLE @txttablename ( @txtcolumn1 adText adParamInput txtcolumn1, @txtselect1 adText adParamInput txtselect1, @txtcolumn2 adText adParamInput txtcolumn2, @txtselect2 adText adParamInput txtselect2, @txtcolumn3 adText adParamInput txtcolumn3, @txtselect3 adText adParamInput txtselect3, )
asp:-
' Declare variables
<%
Dim cmdcreatetable
Dim txttablename
Dim txtcolumn1
Dim txtselect1
Dim txtcolumn2
Dim txtselect2
Dim txtcolumn3
Dim txtselect3
' Get values from form
txttablename = Request.Form("txttablename")
txtcolumn1 = Request.Form("txtcolumn1")
txtselect1 = Request.Form("txtselect1")
txtcolumn2 = Request.Form("txtcolumn2")
txtselect2 = Request.Form("txtselect2")
txtcolumn3 = Request.Form("txtcolumn3")
txtselect3 = Request.Form("txtselect3")
' Set Command
Set cmdcreatetable = Server.CreatObject("ADODB.Command")
cmdcreatetable.ActiveConnection = strConn
cmdcreatetable.CommandText = sp_createtable
cmdcreatetable.CommandType = adCmdStoredProc
' Add Parameters
cmdcreatetable.Parameters.Append.CreateParameter("@txttablename", adText, adParamInput, txttablename)
cmdcreatetable.Parameters.Append.CreateParameter("@txtcolumn1", adText, adParamInput, txtcolumn1)
cmdcreatetable.Parameters.Append.CreateParameter("@txtselect1", adText, adParamInput, txtselect1)
cmdcreatetable.Parameters.Append.CreateParameter("@txtcolumn2", adText, adParamInput, txtcolumn2)
cmdcreatetable.Parameters.Append.CreateParameter("@txtselect2", adText, adParamInput, txtselect2)
cmdcreatetable.Parameters.Append.CreateParameter("@txtcolumn3", adText, adParamInput, txtcolumn3)
cmdcreatetable.Parameters.Append.CreateParameter("@txtselect3", adText, adParamInput, txtselect3)
' Execute the command
cmdcreatetable.Execute
%>SQL Server doesnt like the @ symbol but I dont know how else to do this.
the asp code - the select text boxes are for the user to input datatype.
Thanks for all you help! all ideas greatly appreciated!
GLT
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 1
Solved Threads: 0
Ive been having aply with my code and trying to find information on this. It looks like I have to use dynamic SQL which I have never used before. Here is the SQL code I have now:-
is this right? my SQL Server is down at the minute so I cant test it. I am trying to insert the tablename, column names and datatype from as asp form.
ideas would be great!
Thanks GLT
CREATE PROCEDURE sp_createtable ( @txttablename as varchar(50), @column1 as varchar(50), @select1 as varchar (50), @column2 as varchar(50), @select2 as varchar(50), @column3 as varchar(50), @select3 as varchar(50) ) AS DECLARE @SQL varchar(2000) SELECT @SQL = 'create Table' + @txttablename+')' SELECT @SQL = @SQL + 'ID identity NOT NULL PRIMARY KEY, @txtcolumn1 @txtselect1, @txtcolumn2 @txtselect2, @txtcolumn3 @txtselect3)' Exec(@SQL)
is this right? my SQL Server is down at the minute so I cant test it. I am trying to insert the tablename, column names and datatype from as asp form.
ideas would be great!
Thanks GLT
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,907
Reputation:
Rep Power: 9
Solved Threads: 216
Sorry I can't advice in regards of last 2 posts as I'm more Java and MySQL oriented. The SQL statement that you wrote is different from what I normaly use. Currently I'm also looking into C#, maybe you will find useful chap.21&22 from C# for Programmers, Second Edition that is from Deitel Developer Series
I can discuse designer issues in regards of your project, however for practical problem solving you better post your questions in ASP.NET section of this forum
I can discuse designer issues in regards of your project, however for practical problem solving you better post your questions in ASP.NET section of this forum
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
age amd avatar backup blue gene breach business chips daniweb data data protection database development dos economy energy enterprise europe government gpt guid partition table hacker hardware hp ibm ibm. news intel ibm linux medicine memory microsoft news open source openoffice partition pc ps3 recession red hat security server sun supercomputer supercomputing survey technology trends ubuntu working x86
- adding new database tables and columns through dreamweaver??? (ASP)
- Datagrid scroll bar and field/column name (ASP.NET)
- Online voting (PHP)
- Error from dbms_lob.writeappend (MS SQL)
- alphanumeric autonumber (Visual Basic 4 / 5 / 6)
- Adding a column to an SQL database (VB.NET)
- An OpenSource Database (C++)
- Inventory Control Database Design (Costing Methods) (Database Design)
- insert csv file into mysql through php (PHP)
Other Threads in the MS SQL Forum
- Previous Thread: Trigger updated values not as expected
- Next Thread: Create an extra table (copy the columns and new table) for every existing table



Linear Mode