SQL Query Error - using Request.QueryString

Results 1 to 2 of 2

Thread: SQL Query Error - using Request.QueryString

  1. #1
    Alan Parrott Guest

    Default SQL Query Error - using Request.QueryString

    I&#039;m attempting to use a SQL Query constructed in the following manner<BR>&#060;%<BR>set View = Server.CreateObject("ADODB.Recordset")<BR>View.Act iveConnection = MM_puchasing_STRING<BR>View.Source = "SELECT * FROM dbo." & Request.QueryString("Table_Nm") <BR>View.CursorType = 0<BR>View.CursorLocation = 2<BR>View.LockType = 3<BR>View.Open()<BR>View_numRows = 0 %&#062;<BR><BR>This works fine...when I make the following change <BR>View.Source = "SELECT * FROM dbo." & Request.QueryString("Table_Nm") & "WHERE ID = 2"<BR><BR>The page breaks with the following error...<BR><BR>Error Type:<BR>Microsoft OLE DB Provider for SQL Server (0x80040E21)<BR>The requested properties cannot be supported.<BR><BR>I&#039;ve also tried assembling the query using the following syntax <BR>&#060;%<BR>Set Conn = Server.CreateObject("ADODB.Connection")<BR>conn.op en MM_purchasing_STRING<BR>SQLStmt = "SELECT * FROM" & Request.QueryString("Table_Nm")<BR>SQLStmt = SQLStmt & "WHERE ID = 2<BR>Set RS = Conn.Execute(SQLStmt)<BR><BR>It still fails...If I hardcode a table name and join the query under one set of quotes it works perfectly. <BR><BR>I&#039;m using the following URL .../update.asp?ID=2&Table_Nm=Laptops<BR><BR>I&#039;ve triple checked the simple things...I&#039;m starting to think that ASP can&#039;t handle a dynamically generated table name IF its followed by a WHERE Clause...I&#039;m not sure of the internals of ASP so am unable to verify this...<BR><BR>Any help would be greatly appreciated..<BR>

  2. #2
    Join Date
    Dec 1969

    Default See answer here...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts