Using Strongly Typed Datasets

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

Environment: VS.NET 2003; VB, Access 2003 database. The application allows
users to specify the path/filename and the table name at runtime.

I am trying to figure out how I can use a strongly typed dataset in this
environment. If I add an OleDBDataAdapter to my project and then create a
dataset from that the table name is embedded in the generated code. I
believe that changing the file/path is accomplished by making the connection
string use a variable that contains the user's path/filename but I am not
sure how to handle the fact that the table name changes at runtime.

Can anyone point me to some documentation or examples that will help me
understand how to do this?
 
Wayne Wengert said:
Environment: VS.NET 2003; VB, Access 2003 database. The application allows
users to specify the path/filename and the table name at runtime.

I am trying to figure out how I can use a strongly typed dataset in this
environment. If I add an OleDBDataAdapter to my project and then create a
dataset from that the table name is embedded in the generated code. I
believe that changing the file/path is accomplished by making the connection
string use a variable that contains the user's path/filename but I am not
sure how to handle the fact that the table name changes at runtime.

Can anyone point me to some documentation or examples that will help me
understand how to do this?

--

Just use the the DataAdapter.Fill(DataTable) overload.

eg
dim con as new oledbconnection("..." & someFile & "...")
con.open
Dim ds as new ds_MyTypedDataset
dim cmd as new OleDbCommand("select * from " & someTable,con)
dim da as new OleDbDataAdapter(cmd)
dim dt as DataTable = ds.MyTypedTableRows
da.Fill(dt)

David
 
Wow - that's too easy. I assumed I'd have to do all sorts of tricks.

Thanks

Wayne
 
After some experimenting I realized that this does not update the table name
used in the DELETE, INSERT and UPDATE strings.

Wayne
 

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

Back
Top