Hi jitganguly,
First thanks for taking the time to provide some insight.
You asked: "Why do you have to open connection in a LOOP ?"
Actually that is the last place I want it. I'd like to open a connection and close it outside the the loop. Unfortunately having everything in the loop was the only way I could get it to work. Laughing at myself-- clearly after one day of migrating these scripts from php to asp.net I have a ton to learn.
I will give your method a shot. Thank you very much!
Julian
Main Topics
Browse All Topics





by: jitgangulyPosted on 2004-12-28 at 12:43:01ID: 12914862
My first Q
e=XXX;uid= XXX;passwo rd=XXX;" />
ettings["C onnectionS tring"]; t_string); l_connect_ string); tionString );
); ader(); xDate; ring()); ; ();
Why do you have to open connection in a LOOP ?
There are various ways to have it connected, I use web.config
<appSettings>
<add key="ConnectionString" value="server=XXXX;databas
</appSettings>
and then in pages
if (!IsPostBack)
{
string local_connect_string = ConfigurationSettings.AppS
string strSQL="select * from mytable";
SqlConnection myConnectionString = new SqlConnection(local_connec
SqlDataAdapter myData = new SqlDataAdapter(strSQL,loca
SqlCommand myCommand = new SqlCommand(strSQL,myConnec
SqlDataReader dxDate=null;
try
{
myCommand.Connection.Open(
dxDate=myCommand.ExecuteRe
DropDownList1.DataSource=d
DropDownList1.DataBind();
}
catch(Exception ae)
{
Response.Write("An Error Occured displaying this Page .....<br>"+ae.Message.ToSt
Response.End();
}
finally
{
myConnectionString.Close()
myCommand.Connection.Close
}
}
}