MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old October 26th, 2002, 10:15 PM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
recordset object with ASP and MySQL - updating and deleting

Is it possible to use the recordset object to update and delete your database records when you are using ASP with MySQL? I know you can use it to add new records, but when I've tried using it to update and delete, it always fails. I've had to use the execute method with the connection object instead and write out the SQL statement (UPDATE tableName SET ..... etc.)

Does anybody have any information on this issue?

Thanks,
IS

Reply With Quote
  #2  
Old November 13th, 2002, 02:19 PM
praveen praveen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: india
Posts: 7 praveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 13 sec
Reputation Power: 0
I don't see any problem in updating or deleting mysql records with asp.
I tried both using
connection.Execute(string) and
ADODB.Recordset object

Regards
Praveen

Reply With Quote
  #3  
Old November 14th, 2002, 09:40 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Let's see your code for the update and delete - maybe that's where the problem lies?

Reply With Quote
  #4  
Old November 16th, 2002, 08:04 PM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
code for update/delete using MySQL

Here is a snippet of code I've used that doesn't work with MySQL, but has worked just fine using SQL Server.

dim intCategoryID
intCategoryID = request ("categoryID")

dim rsCategories, qryCategories
set rsCategories = server.createObject ("ADODB.recordSet")
qryCategories = "SELECT * FROM tblCategories WHERE categoryID = " & intCategoryID
rsCategories.open qryCategories, connect, adOpenStatic, adLockOptimistic

rsCategories ("categoryName") = request ("categoryName")
rsCategories.update

rsCategories.close
set rsCategories = nothing

Seems pretty straightforward, no? Well, I get an error that says something to the effect of "multi step OLE DB operation generated errors. Check each status value." And yes, a value for request ("categoryName") (and all the other variables for that matter) is most definitely present.

In order to do the update, I have to do it implicitly with an SQL update statement using connect.execute. I guess that's ok, it's just odd that I can't use the recordset object. I figured it's because MySQL doesn't natively support ADO.

Reply With Quote
  #5  
Old November 16th, 2002, 08:56 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
looks fine to me. Here's some troubleshooting suggestions about the error message you got. Maybe they might help?

http://www.aspfaq.com/show.asp?id=2288

Sometimes I have problems with a Select * statement and a request for an id (is it a request.Querystring or request.form?). When you do a response.write after the select statement, you actually get any records?

If it's any consolation, using update and delete statements instead of a recordset are better from a performance standpoint.

Reply With Quote
  #6  
Old November 16th, 2002, 09:20 PM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The process is request.form. I never tried writing out request.form; I usually just write request for short.

Since the error could be a datatype issue, I started wondering if perhaps it might be because of the data type I've defined in MySQL for this field. I was using TINYTEXT for the field in question. Perhaps if it was a varchar type ADO would like that better? I think that may be the only thing I haven't tried. It's just puzzling that I can use the addNew method but I can't update a recordset.

Thanks for the info you sent me.

Reply With Quote
  #7  
Old November 17th, 2002, 10:01 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
ur welcome.

I remember reading somewhere that it's better to use the full request.querystring or request.form (although I can't remember off hand what the reason was!). There is something on this at http://www.aspfaq.com/show.asp?id=2111. So since then, I've been writing it out in full.

Yes, you would think that if you can use AddNew you should be able to use ADO to update. Very frustrating. Let me see if I can try the code here. Your catagories table just has CatagoryID and CatagoryName, right?

Reply With Quote
  #8  
Old November 17th, 2002, 10:12 AM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, that is correct. Those are the only two fields in the table. The ID is an autonumber primary key.

Reply With Quote
  #9  
Old November 17th, 2002, 07:44 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
I have a feeling your problem is in your recordset.open statement. You are using

rsCategories.open qryCategories, connect, adOpenStatic, adLockOptimistic

I think u need the dynamic cursor. Give this a shot

rsCategories.open qryCategories, connect, 2, 3

Hope that does the trick. Failing that - Whack the error msg into google, that's usually the best way to solve your problems.

stumpy.

Reply With Quote
  #10  
Old November 17th, 2002, 09:29 PM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Good thought on the different cursor type. I've tried using adOpenDynamic and adLockPessismistic in various combinations with no luck.

I had thought also that maybe the data type I had defined in the MySQL database was causing problems, so I changed it from tinytext to varchar. Still no luck.

Maybe it's a limitation of the MyODBC version installed (and therefore a limitation of the ISP) or that I need to be using a different option in the connection string when I connect to the database? When I refer to connection options, I'm referring to the numerical list here: http://www.mysql.com/doc/en/MyODBC_...parameters.html

I really know nothing about those connection options, so I've not ever used them or experimented with them before. Perhaps some of you know more about what they mean (the descriptions with them on the mysql.com page listed above I've found to not be very extensive).

It's an odd problem, but since I can use the update, delete, and insert statements, it hasn't forced me to cease my programming entirely!

Reply With Quote
  #11  
Old November 18th, 2002, 09:38 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
I couldn't get it to work either and the error seemed to be related to the adOpenStatic, adLockOptimistic.

You might want to take a look at:

http://www.mysql.com/products/myodb...#MyODBC_With_VB

which "contains simple samples on the usage of MySQL ODBC 3.51 Driver with ADO, DAO and RDO. "

Reply With Quote
  #12  
Old January 10th, 2003, 06:54 PM
paulskinner paulskinner is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 2 paulskinner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smithim,

I am having exactly the same problem you describe, but with a different error -

Syntax error or access violation: You have an error in your SQL syntax near 'code='pasapsk' WHERE ID= 2 And Price= 49 And Available= -1 ' at line 1

Will try your method, but would be interested to know if you ever got the update method to work.

Skinner

Reply With Quote
  #13  
Old January 10th, 2003, 07:01 PM
smithim smithim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 12 smithim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No, never did get it to work. What I always had to end up doing was using UPDATE and DELETE queries to modify or delete records with ASP. Oddly enough, however, I am usually able to add records using ADO. Even then, sometimes I found there was more consistency in successfully inserting records when I used an INSERT query.

Reply With Quote
  #14  
Old January 11th, 2003, 06:10 AM
paulskinner paulskinner is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 2 paulskinner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Same thing here, although the error message I was getting was due to a field in the database containing a space, and not enclosing it within "`"s.

Never mind. I'll carry on using the queries. Thanks for your prompt reply.

Skinner

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > recordset object with ASP and MySQL - updating and deleting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |