A
Alex
Hey all -
I've found a lot of 'snippet' examples of hitting a sqlserver db from a
csharp windows app, but I want to make sure I understand the proper usage.
In the examples, they usually create the sqlconnection and pass the
connection string in the form, and then open it and create a sqlDataAdapter
to load a widget... immediately following the sqlconnection is closed.
For what I want to accomplish, I'm going to have many forms coming off of a
MDI control window. Would the following be ok?
1. Create a static sqlconnection in a static dbaccess class
2. Open the connection, create the dataadapter/dataset to load the widget,
close the connection.
3. Repear #2 for each data bound widget on each form...
Do I need to create a different dataadapter for each widget that I want to
populate from the db?
Do I need to close the connection after each hit, or can I just keep it
open for the entire time they have the app running?
Just trying to get a handle on how the small examples I've found apply to a
larger application...
Thanks!
I've found a lot of 'snippet' examples of hitting a sqlserver db from a
csharp windows app, but I want to make sure I understand the proper usage.
In the examples, they usually create the sqlconnection and pass the
connection string in the form, and then open it and create a sqlDataAdapter
to load a widget... immediately following the sqlconnection is closed.
For what I want to accomplish, I'm going to have many forms coming off of a
MDI control window. Would the following be ok?
1. Create a static sqlconnection in a static dbaccess class
2. Open the connection, create the dataadapter/dataset to load the widget,
close the connection.
3. Repear #2 for each data bound widget on each form...
Do I need to create a different dataadapter for each widget that I want to
populate from the db?
Do I need to close the connection after each hit, or can I just keep it
open for the entire time they have the app running?
Just trying to get a handle on how the small examples I've found apply to a
larger application...
Thanks!