473,418 Members | 1,749 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,418 software developers and data experts.

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

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.
************************************************** *********************
Nov 23 '05 #1
2 1003
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. :)
Nov 23 '05 #2
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.
************************************************** *********************
Nov 23 '05 #3

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

Similar topics

0
by: Naveen | last post by:
Hi, Is the data repeater and datalist control available for win forms? if not, then are there any alternatives available? -Naveen
1
by: Danky | last post by:
Hello Everybody, How Can I Enable Edit some columns on Control Datagrid and lock edit others? Is it posible on Control DataGRid of VB.Net? I Accept some link, example or any resource. ...
1
by: VIswanathan S | last post by:
Hi All! How to use Data Repeater in VB.NET? Data Fields are Employee Number Name Photo Date of Joining Salary
2
by: Carolyn Vo | last post by:
I have been looking and looking but can't seem to find out how to get the row selected in a web control datagrid (NOT a web form datagrid!!!), and how to highlight the selected row. I'm sure this...
0
by: Nilesh W | last post by:
Hi I am using data repeater in my application to display data. Header template for data repeater I want add at run time because the header text for item columns read from some other resources ...
0
by: hsr | last post by:
I'm trying to find a way to only display a fixed amount of characters from one field in a data repeater. The field that is read into the dataset is much larger, but I only want to display say the...
2
by: Neo Geshel | last post by:
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...
9
by: Robby | last post by:
In my opinion the VB6 Data Repeater has to be the most versatile control ever released by Microsoft. They also sharee this opinion when they released it but I have not been able to find its .Net...
0
by: SimonZ | last post by:
I have data repeater. One of the row is defined: <ItemTemplate> <asp:TableCell > <%If viewState("type") = "3" then%> <%# writeLine(DataBinder.Eval(Container.DataItem, "name")%> <%else%>...
2
by: mikeyatsony | last post by:
Hi all... I've been training a little on the whole ASP.NET and would like to know how someone would use the data repeater like this: For example, I have some data coming from a table and let's...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.