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.