Need ConnectionString text when using ADO.NET DataTable as source

G

Gregory Correll

I'm attempting to use an existing ADO.NET DataTable as a data source
for localized queries. Does anyone have the ConnectionString text
when using an existing code-generated DataTable as the source for the
queries?

Ex:

DataTable source = GetDataTableFromSomewhere();
string sql = GetComplexSqlStatementFromSomewhere();
OleDbCommand command = new OleDbCommand(sql);

command.Connection = new OleDbConnection( ???Connect to the source
DataTable??? );

OleDbDataAdapter adapter = new OleDbDataAdapter(command);
DataSet newDS = new DataSet();
adapter.Fill(newDS);
myGrid.DataSource = newDS.Tables[0];

Thanks,
Greg
 
J

Jason L James

Greg,

in order to create the table it would have to be inserted into
an existing .sdf file. Surely that is the file you need for your
connection string.

Dim myConn As New SqlCeConnection("Data Source = \My
Documents\filename.sdf")

Once you have that you should be able to attach to the
DB and do whatever you wish.

The only other way I know of using a code generated table
is when it is created inside a dataset in memory. This too
should have a name.

myDataSet.Tables("newTableName")

Good luck, and let us know how you get on.

Jason.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top