[quoted text, click to view] "Giacomo" <anonymous@msnewsgroups.com> wrote in message
news:uZ4MAmkLEHA.268@TK2MSFTNGP11.phx.gbl...
> --SELECT name from sysobjects where name=@tabla
>
> Can you explain your situation a bit more? I'm not sure I understand your
> question.
>
I believe I know what the OP wants to do, and I believe it can be done in
ADO.NET.
She wants to create a parameterized SELECT query where the table name for
the query can be supplied as a parameter.
Write a general query.
SELECT * FROM "tablename"
where "tablename" is supplied as an argument just before the query runs.
As SQL commands are set up as strings in ADO.NET, then attached as
properties of data adapter objects (SQLDataAdapter, etc.). It would be
possible to prompt the user for the desired table name (probably from a
list), then incorporate the selection in the cmdSelect.CommandText property.
Sort of like this:
mconCurrent.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=..\..\..\Data\Factory.mdb"
Dim dtmtblFactory As DataTableMapping
dtmtblFactory = modbdaCurrent.TableMappings.Add("Table", "tblFactory")
' Build the SelectCommand to select all of the records from the table
' named tblFactory.
modbcmdSelect.CommandText = "SELECT * FROM tblFactory "
modbcmdSelect.Connection = mconCurrent
modbdaCurrent.SelectCommand = modbcmdSelect
Prompt the user (or obtain from another source) for the String containing
the desired table and substitute for the literals in the code.
Caveat: I have not tried this, so it should be regarded as an experiment.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.