Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 14th, 2004, 07:00 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old November 15th, 2004, 03:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #3 (permalink)  
Old November 15th, 2004, 03:36 AM
Registered User
 
Join Date: Nov 2004
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old November 15th, 2004, 03:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

It was just for your information.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:24 AM.


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