Last post Jun 09, 2009 07:26 PM by knappm
Jun 04, 2009 02:13 PM|knappm|LINK
Hi There -
I've got an aspx page that INSERTs rows into a table via a LISTVIEW..... however, the table name needs to be variable based on user selection from the referring page. Right now, the table name is being passed to the page via querystring.
My INSERT statement works just fine if I test it by hardocding a table name. For example:
InsertCommand = "Insert INTO [my table name] (prjParcel_Serial) values (@prjParcel_Serial)"
However, as soon as I switch the table name to a variable (as in the example below), it doesn't work:
InsertCommand = "Insert INTO @project (prjParcel_Serial) values (@prjParcel_Serial)"
The error returned is: "Syntax error in query. Incomplete query clause."
My Parameters are shown below:
<asp:QueryStringParameter Name="project" QueryStringField="project" />
<asp:Parameter Name="prjParcel_Serial" Type="String" />
Am I missing something?
Jun 04, 2009 04:38 PM|Mikesdotnetting|LINK
I doubt you can use parameters for table names. You will have to build that part fo the SQL statement dynamically.
Jun 09, 2009 07:26 PM|knappm|LINK
Thanks for the reply. I believe you are correct about not being able to use parameters for table names.. or at least I had no success with it.
However, I was able to declare a variable table name by grabbing the querystring and dynamically generating the SQL query statement and then setting my
AccessDataSource InsertCommand using the OnLoad event of the AccessDataSource.
This worked just fine and had the same effect as if the table name were a parameter (at least for my purposes).