Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Adding external data into database data before it is sent to Control(Repeater, Datagrid, etc.)

Reply
Thread Tools

Adding external data into database data before it is sent to Control(Repeater, Datagrid, etc.)

 
 
Neo Geshel
Guest
Posts: n/a
 
      11-13-2005
I am looking to add additional data into a "stream" that has been
extracted from a database, but before it is sent to a control (Repeater,
in this case).

I have found ZERO (0) articles about this on the Internet. Anyone care
to point me in the right direction? I am not looking for code that
rivals Gray's Anatomy in complexity, just something that can add a
static variable in a line or two of code (at the most).

My script so far looks like this:

Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings( "strConn"))
Dim myCmd_img as New OleDbCommand("SELECT [ID], [Comment] FROM [tbl"
& strSlave & "] WHERE [" & strMaster & "ID] = " & intMaster & " AND [ID]
= " & intSlave, myConn)
myConn.Open()
Img.DataSource = myCmd_img.ExecuteReader(CommandBehavior.CloseConne ction)
Img.DataBind()
myConn.Close()

What I want to do is add the table name, contained within the string
strSlave, into the data extracted from the table. I want to assign it a
variable of "Table". That way, I can call it by its variable in the
Repeater.

I do not want to add the name of the table TO the database, I just want
to add it to the stream of data extracted FROM the database. Ideally, it
would be something as simple as this:

Img.Items.Insert(0, new Item(strSlave, "Table"))

But this doesn't work.

TIA,
...Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
“Anyone who believes in Intelligent Design (“creationism”) is just as
ignorant and ill-educated as someone who believes that the world is
flat, that the Sun circles the Earth or that there really is a tooth
fairy. Darwinism has an overwhelming foundation of evidence that can be
tested and reproduced. Intelligent Design, on the other hand, has no
evidence at all; not one single shred of testable proof. As such,
Intelligent Design is Religious Mythology, and has no right whatsoever
to be in our Science classrooms.” - 99.99+% of Scientists
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
 
Reply With Quote
 
 
 
 
Chris Priede
Guest
Posts: n/a
 
      11-13-2005
Hi,

Neo Geshel wrote:
> Dim myCmd_img as New OleDbCommand("SELECT [ID], [Comment] FROM
> [tbl" & strSlave & "] WHERE [" & strMaster & "ID] = " & intMaster & "
> AND [ID] = " & intSlave, myConn)


> I do not want to add the name of the table TO the database, I just want
> to add it to the stream of data extracted FROM the database.


You can achieve exactly what you want by adding to your SQL query. You can
SELECT not just table columns, but also literal values: nothing stops you
from doing the following:

Dim myCmd_img as New OleDbCommand("SELECT 'tbl" & strSlave & "' AS [Table],
[ID], [Comment] FROM
[tbl" & strSlave & "] WHERE [" & strMaster & "ID] = " & intMaster & "
AND [ID] = " & intSlave, myConn)

I hope I did the VB concatenation right (I am not a VB programmer). The
SQL we are going for is: "SELECT 'tblWhatever' AS [Table], ..." -- note the
single quotes around the literal value. This will return an additional
column named "Table" and containing the given value, for each returned row.

--
Chris Priede

P.S. I hate concatenated queries -- consider using parameters.


 
Reply With Quote
 
 
 
 
Neo Geshel
Guest
Posts: n/a
 
      11-17-2005
Chris Priede wrote:
> Neo Geshel wrote:
>> Dim myCmd_img as New OleDbCommand("SELECT [ID], [Comment] FROM
>>[tbl" & strSlave & "] WHERE [" & strMaster & "ID] = " & intMaster & "
>>AND [ID] = " & intSlave, myConn)

>
>>I do not want to add the name of the table TO the database, I just want
>>to add it to the stream of data extracted FROM the database.

>
> You can achieve exactly what you want by adding to your SQL query. Youcan
> SELECT not just table columns, but also literal values: nothing stops you
> from doing the following:
>
> Dim myCmd_img as New OleDbCommand("SELECT 'tbl" & strSlave & "' AS [Table],
> [ID], [Comment] FROM
> [tbl" & strSlave & "] WHERE [" & strMaster & "ID] = " & intMaster & "
> AND [ID] = " & intSlave, myConn)
>
> I hope I did the VB concatenation right (I am not a VB programmer). The
> SQL we are going for is: "SELECT 'tblWhatever' AS [Table], ..." -- note the
> single quotes around the literal value. This will return an additional
> column named "Table" and containing the given value, for each returned row.
>

Actually, this works beautifully, I just had to add my values after any
SQL SELECT operations (such as “SELECT TOP 1”) and beforethe FROM.
Otherwise Access chokes on the statement.

Thanks.
...Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
“Anyone who believes in Intelligent Design (“creationism”) is just as
ignorant and ill-educated as someone who believes that the world is
flat, that the Sun circles the Earth or that there really is a tooth
fairy. Darwinism has an overwhelming foundation of evidence that can be
tested and reproduced. Intelligent Design, on the other hand, has no
evidence at all; not one single shred of testable proof. As such,
Intelligent Design is Religious Mythology, and has no right whatsoever
to be in our Science classrooms.” - 99.99+% of Scientists
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
How to get access to the complete HTML just before its sent to the client Rahul Agarwal ASP .Net 3 08-06-2004 04:06 PM
Tools to extract data from SQL database and convert it into XML & insert XML data into SQL databases Harry Zoroc XML 1 07-12-2004 10:10 PM
Catching ChildControl render output and modify before sent out Ron Vecchi ASP .Net 4 10-31-2003 06:25 AM



Advertisments