After experiencing a lot of down time, We decided to move this site to
CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.
Can a SQL statement take a table name as parameter?
|
Author |
Message
|
amir1359
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 12/12/2009
-
Status: offline
|
Can a SQL statement take a table name as parameter?
Saturday, December 12, 2009 7:20 PM
( permalink)
Hi i am sure there is way to get the table name as a parameter but i could not find the correct syntax <% Dim rs Dim rs_numRows Dim dynamicTable // this is the var which keep my parameter posted by querystring (which is tableName) dynamicTable =request("tableName") Set rs = Server.CreateObject("ADODB.Recordset") 'rs.ActiveConnection = MM_conn1_STRING // this is my conn string to open the record set rs.Source = "SELECT * FROM " + dynamicTable // this is my broblem 'rs.Source = "SELECT * FROM ComplainList" rs.CursorType = 0 rs.CursorLocation = 2 rs.LockType = 1 rs.Open() rs_numRows = 0 %> As i have mentioned in the code the time which i use "SELECT * FROM ComplainList" as my source , i dont have any problem but the time i use "SELECT * FROM " + dynamicTable .. i get syntax error which say FROM clause syntax error!! please teach me ,what to do??
|
|
|
|
centauricw
-
Total Posts
:
42
- Scores: 2
-
Reward points
:
0
- Joined: 2/20/2006
-
Status: offline
|
Re:Can a SQL statement take a table name as parameter?
Friday, December 25, 2009 2:02 PM
( permalink)
Instead of rs.Source = "SELECT * FROM " + dynamicTable try rs.Source = "SELECT * FROM " & dynamicTable The ampersand ( & ) is the correct concatenation operator for joining strings.
|
|
|
|
Online Bookmarks Sharing: