Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Creating tables etc...


Message #1 by "Eimear Flynn" <flynneimear@h...> on Thu, 31 Jan 2002 14:23:13
Hi everybody, im in need of your help.



I need to know if  it is possible to create a table in an asp page by 

providing the user with a form and text boxes for the table name and field 

names and a combo box to allow them to select the data type for each 

field, and then using the values in these text boxes to create a table 

through sql. Ive tried it using the following syntax but am not sure if 

its the wrong syntax or if im just completely on the wrong lines :



<%

dim strTableName, strFieldName, strDataType, strPrimKey



strTableName = request.form("TableName")

strFieldName = request.form("FieldName")

strDataType = request.form("DataType")

strPrimKey = request.form("PrimKey")

%>



<%          

dim stateSQL



If request.form("PrimKey") = "on" then

set stateSQL = "CREATE TABLE request.form(""TableName"")(strFieldName 

strDataType(30) not null constraint strFieldName primary key)"

else

stateSQL = "CREATE TABLE request.form(""TableName"")(strFieldName 

strDataType(30))"

end if



'objConn.execute 



set objRS = server.createobject ("ADODB.recordset")

objRS.open strTableName, objConn

response.write "strTableName Table :"

response.write RecToTable(objRS)

objRS.close

set objRS = Nothing





objConn.close

%> 



ive also added two include files, on to open the connection to the 

database where i want to add the table and one called RecToTable which 

will display the table when the user has created it.



I would also like to know if it is possible to provide the user with a 

combo box in an asp page which can display all of the table names in the 

access database and allow them to select a table name and when they click 

on the submit button the following page would display the table.



Thanks for your time, hope someone can help me.

Thanks again,

Eimear

  Return to Index