Hi,
Im after some advice on how i go about opening my sqlConnection. At the moment when my program is first run i open the sqlConnection and this is made as a public object so i can reference throughout the program without having to close it untill i close the program. I thought this was fine untill i came into problems when using the sqlDataAdapter as i was getting the error:
'There is already an open DataReader associated with this Command which must be closed first'
After reading some forums, i kind of get the feeling i shouldnt have the connection open all the time.
Is this correct, or should i create and close another connection only when using the sqlDataAdapter.
My code keeps falling over here:
sqlDa.Fill(dt)
This is in a method that gets called when i click my refresh button to repopulate a dataGridView.
Thanks for any help.
Im after some advice on how i go about opening my sqlConnection. At the moment when my program is first run i open the sqlConnection and this is made as a public object so i can reference throughout the program without having to close it untill i close the program. I thought this was fine untill i came into problems when using the sqlDataAdapter as i was getting the error:
'There is already an open DataReader associated with this Command which must be closed first'
After reading some forums, i kind of get the feeling i shouldnt have the connection open all the time.
Is this correct, or should i create and close another connection only when using the sqlDataAdapter.
My code keeps falling over here:
sqlDa.Fill(dt)
This is in a method that gets called when i click my refresh button to repopulate a dataGridView.
Thanks for any help.