|
Subject:
|
Connection problem
|
|
Posted By:
|
atzplzw
|
Post Date:
|
11/14/2004 6:00:54 PM
|
Hi!
I use the following code to access a mdb file with a asp.net project:
OleDbConnection con = new OleDbConnection(strDbConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT COUNT(*) FROM login WHERE Email=@ParamEmail";
cmd.Parameters.Add("@ParamEmail", TbxEmail.Text);
object oResult = cmd.ExecuteScalar();
string lldt = DateTime.Now.ToString();
cmd.CommandText = "UPDATE login SET LastLogin=@ParamDate WHERE Email=@ParamEmail";
cmd.Parameters.Add("@ParamDate", lldt);
cmd.Parameters.Add("@ParamEmail", TbxEmail.Text);
cmd.ExecuteNonQuery();
con.Close();
cmd.Dispose();
con.Dispose();
The problem is that the second cmd.ExecuteNonQuery() does fail! I mean it doesn't fail with any error message or anything. It just doesn't do anything, no matter what I try! Both .Execute work fine when they are used ALONE! But if I use them in a row the second one doesn't do anything. Since this is a Web-App I thought in terms of speed I can reuse the connection. Do I have to establish a new one everytime I use a .Execute command? Or is there another problem with this code?
Thanks for help! atzplzw
|
|
Reply By:
|
happygv
|
Reply Date:
|
11/15/2004 2:26:15 AM
|
How about posting that on a .NET forum here? This is a classic ASP forum.
_________________________ - Vijay G Strive for Perfection
|
|
Reply By:
|
atzplzw
|
Reply Date:
|
11/15/2004 2:36:47 AM
|
Sorry!
I already got an answer at another forum which is:
//Cleanup parameters before second .Execute... cmd.Parameters.Clear();
So mods can move this or del.
atzplzw
|
|
Reply By:
|
happygv
|
Reply Date:
|
11/15/2004 2:53:12 AM
|
It was just for your information.
_________________________ - Vijay G Strive for Perfection
|