Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can make an INSERT INTO statement see a variable?

Status
Not open for further replies.

gtubb

Programmer
Jan 15, 2004
24
GB
Hi

Can anyone tell me how I can get a table name passed in the URL (page.asp?=blah)to work with the INSERT INTO code below? My attempts with

dim strTblename
strTblename = Request.Querystring("Table")
SQL = "INSERT INTO strTblename

just returns the error message "Could not find output table 'strTblename'"

How can I make it see the 'blah' table name I have passed in the URL?

Thanks.

This is my (not working) script:

<%Set Upload = Server.CreateObject(&quot;Persits.Upload&quot;)

Upload.Save &quot;c:\upload&quot;

Set File = Upload.Files(&quot;THEFILE&quot;)

If Not File Is Nothing Then

Connect = &quot;Driver={Microsoft Access Driver (*.mdb)};&quot; &_
&quot;DBQ=&quot; & Server.MapPath(&quot;config/datasources/aspupload.mdb&quot;)

dim strTblename
strTblename = Request.Querystring(&quot;Table&quot;)

SQL = &quot;INSERT INTO strTblename(image_blob, filename, description, filesize) VALUES(?, '&quot;
SQL = SQL & File.Filename & &quot;', '&quot;
SQL = SQL & Replace(Upload.Form(&quot;DESCR&quot;), &quot;'&quot;, &quot;''&quot;) & &quot;', &quot;
SQL = SQL & File.Size & &quot;)&quot;


File.ToDatabase Connect, SQL
Response.Write &quot;File saved.&quot;
Else
Response.Write &quot;File not selected.&quot;
End If
%>


 
dim strTblename
strTblename = Request.Querystring(&quot;Table&quot;)

SQL = &quot;INSERT INTO &quot; &_
strTblename &_
&quot; (image_blob, filename, description, filesize) VALUES(?, '&quot;


etc

hth,
Foxbox
 
Thank you. When this site is finished I'll owe you several beers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top