473,379 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 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
Jul 18 '08 #1
3 2825
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
Jul 18 '08 #2
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" <ra****@plug-in.ita écrit dans le message de groupe de
discussion : Os**************@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 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
Jul 18 '08 #3
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" <ra****@plug-in.itwrote in message
news:Os**************@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 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

Jul 18 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Doug Baroter | last post by:
Hi, The following script does not return any resultset against a test db while I know for a fact tables with letter "aaa" has columns that contains "ccc". What's wrong? the the inner cursor? ...
4
by: Andre Arpin | last post by:
I am new at sql so would appreciate some help I have the name of a table in alocal variable is it possible to select this table DECLARE @name sysname SET @name = 'tblSniffedItems' PRINT...
41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
2
by: WindAndWaves | last post by:
I recently made a very simple little function: Function x() Dim Tbl As TableDef Dim fld As DAO.Field Set Tbl = currentdb.TableDefs("search") Debug.Print Tbl.Name For Each fld In Tbl.Fields...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
4
by: Steven Smith | last post by:
Hello all, I have a vb6 (not .NET) program using MS Access as the backend. As part of an import form, I need to allow the user to select the table containing the data to be imported. How can I...
13
by: db55 | last post by:
I have >200 tables and I want to create a table that lists the name of each table, the number of records, and the number of locations within the table. I've created a cursor to do this but it...
2
by: philin007 | last post by:
Hi Guys, Could any one help me out with codes to add rows to a table. Well I kinda of got the codes from the following site (http://www.interviewboard.com/DHTMLSamples/DHTMLGridSample.htm) the...
1
by: saranyagunasekaran | last post by:
I have1000 databases with table called tbl1 which has got enrolled as column name, need to get count of enrolled records from tbl1 for all 1000 databases using procedures.............or it would be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.