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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrea Raimondi

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

    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 programmaticall y 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


  • Andrea Raimondi

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

    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


    Comment

    • Patrice

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

      Not sure how you are doing this for now but (if you are using parametized
      queries) basically parameters are not a macro substitution thing i.e. a
      parameter value can't be used in a SQL Statement to provide the table name
      (if can replace "values" not a table name or the name of the fields in the
      SELECT clause etc...).

      Not sure what is your logic but :
      - I would likely hide this with a stored procedure
      - You could also dynamically create the FROM clause.
      - you can isnert data into the tabvle variable using an INSERT statement

      Another option would be to go back earlier in the design. Isn't this table
      part of the union ? If yes you could just always use the union with the
      appropriate criteria. What is the concept difference between this table and
      the union ?

      Bascially the idea would be that this issue is not to be solved at the
      SQLDataSource level. It would be IMO better to hide this behind what is
      exposed by SQL Server....

      --
      Patrice

      "Andrea Raimondi" <raiand@plug-in.ita écrit dans le message de groupe de
      discussion : OseymSL6IHA.348 0@TK2MSFTNGP03. phx.gbl...
      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 programmaticall y 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
      >

      Comment

      • randy.buchholz

        #4
        Re: Declare the table variable &quot;tbl&quot; ... -.-' !?! I just need a table NAME there! -.-'

        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.


        "Andrea Raimondi" <raiand@plug-in.itwrote in message
        news:OseymSL6IH A.3480@TK2MSFTN GP03.phx.gbl...
        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 programmaticall y 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
        >

        Comment

        Working...