Need ConnectionString text when using ADO.NET DataTable as source

  • Thread starter Thread starter Gregory Correll
  • Start date Start date
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
 
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.
 
Back
Top