Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2004, 07:00 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection problem

Hi!

I use the following code to access a mdb file with a asp.net project:

Code:
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

 
Old November 15th, 2004, 03:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about posting that on a .NET forum here? This is a classic ASP forum.

_________________________
- Vijay G
Strive for Perfection
 
Old November 15th, 2004, 03:36 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 15th, 2004, 03:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

It was just for your information.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with the connection! Berni016x SQL Server 2000 2 November 9th, 2004 08:51 AM
PROBLEM IN CONNECTION Abhinav_jain_mca SQL Server 2000 5 September 30th, 2004 09:32 AM
Problem With Connection ! huyremy VB Databases Basics 2 September 29th, 2004 03:37 AM
connection problem weihoe2004 VS.NET 2002/2003 1 July 10th, 2004 01:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.