473,320 Members | 1,879 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,320 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 19 '05 #1
2 1274
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 19 '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 20 '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: 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...
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...
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...
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.