7
Answers

Questions about Dataset, Data adapter and how to show data in a form.

Lars Persson

Lars Persson

12y
3.5k
1
I wonder when you should use a data set and Data adapter and when not to.

Do you have to use data adapter if you want to work disconnected from the database? If you use Data adapter, must you also use dataset?

I understand that dataset is a representation of tables in memory and data adapter is somehow a link between a dataset and the database.

I have this code:

string connectionString = "data source = KONTORET\\sqlexpress; Initial Catalog = testDatabas; Trusted_Connection = True";
           
SqlConnection connection = new SqlConnection(connectionString);
           
connection.Open();
           
string selectStatement = "select * from Cars";
           
SqlCommand command = new SqlCommand(selectStatement, connection);

As I understand it you doesn't need data adapter when you work like this. Do you use a dataset even if you don't say so explicitly?

I would also like to know how to show this in a form.
Answers (7)