Declare the table variable "tbl"... -.-' !?! I just need a table NAME there! -.-'

  • Thread starter Thread starter Andrea Raimondi
  • Start date Start date
A

Andrea Raimondi

Hello peers!

I'm working on this application and I'm in need for some thoughtful advice
:-p

I have an SQLDataSource with params, select, etc.
One of my params is the table name, which can be programmatically set, this
is necessary because I may have a
simple table name or a union, hence I got to pick the correct one!
Unfortunately, I can't bind this parameter to a control, session or
whatever, my table names are embedded in my
source code as a constant array of strings.

Googling around I found out that SQLServer is being mislead by the parameter
position - I just want a table NAME there, not a
table variable!

Is there any way I can tell to the SQLDataSource that I need a table NAME
parameter? :D
Alternatively, how can I populate such a table variable so that it contains
the correct table contents?

Any hints?

TIA,

Andrew
 
Up to now I have tried several ways to make it work:

- wrapping parameter in square brackets(didn't work, it thought it was the
name of the table... sigh!)
- Setting the extended properties and declaring the parameter of type
string(to no avail.... still complaining about the table variable)
- I also thought I'd maybe be luckier declaring the table variable and
using a select, but I'd still be prompted with the usual problem...

Maybe a stored procedure with a parameter would work?

Any ideas?

Andrew
 
I recall SQL Server being qurky about things like this. I had tried writing
some SP's that took the table name as a parameter to build the SQL string
and couldn't get the to work properly. I posted on the SQL Server fourm and
got an explaination of why this is a problem but can't recall. I ended up
passing the name and then using it to hitting the system database to get to
the table.
 
Back
Top