Hey all. I currently have two seperate namespaces and I'm trying to
pass a connection around to them. I want to use the same connection &
leave it open for 6 methods & then close it. However, all 6 of those
methods use that same connection.
So my solution was to pass the SqlConnection as a parameter in each
method. This works, but it goes super slow. When I changed it back
and put the methods all back in the same namespace & didnt pass the
connection object things went *much* faster. Is there a better (i.e.
quicker) way to accomplish this same thing? Maybe passing a connection
string and starting a new connection every time?? I just don't know.
Any help would be greatly appreciated!
namespace MyNameSpace
{
public static getThisID(string strName, sqlConnection sqlDbCon)
{
System.Data.SqlClient.SqlCommand sqlCommand = new
System.Data.SqlClient.SqlCommand();
// I then assign the connection for this command as the passed
sqlDbCon
sqlCommand.Connection = sqlDbCon;
// do the sql command execute code and then exit
}
}
namespace stupid
{
// pass the connection in every method
MyNameSpace.Database.getThisID(string strName, sqlConnection
sqlDbCon)
MyNameSpace.Database.getAnotherID(string strName, sqlConnection
sqlDbCon)
MyNameSpace.Database.getAndYetAnother(string strName, sqlConnection
sqlDbCon)
(8 times)
}