473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 18 '08 #1
3 2840
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 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
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******** ******@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

Jul 18 '08 #4

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

Similar topics

1
1704
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? Thanks.
4
6042
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 @name SELECT * FROM @name
41
6098
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 is one row containing picture(s) as well. So far, what I did is doing it manually for each word docs I have. Select Table Convert Table to Text(I use ^ character for delimiter)
2
4026
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 Debug.Print fld.Name Next fld
1
3544
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 black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for each LinkButton's Click event. This all works fine. Now in the Link Button's Click event...
4
23906
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 populate a combo with this information? Then, once this value is selected, how can I populate other combos with the column names of the selected table? Thanks,
13
3033
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 doesn't like it. I get the following error. Invalid column name '<tablename>'. Here's my script
2
2137
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 problem is this example only shows input box. Now i have a list that means a 'select box' for which the value is retrieved from Database and populated into the select list box. Now according to the example if all residing in the javascript how am i...
1
1693
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 fine...if trigger is being set as soon as databases got created wuth tbl tbl1 and column enrolled to gine count. get me the reply asap..............
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.