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 22nd, 2004, 12:13 PM
Authorized User
 
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to don baroo Send a message via Yahoo to don baroo
Default unable to update MySQL database with ASP

Hi,

I am having a problem and I need help urgently. I am having this error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/practicals/newdata.asp, line 62

Please reply soon.

Thank you.

 
Old November 22nd, 2004, 12:17 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What are you trying to do when the error occurs?

Cheers,

Chris

 
Old November 22nd, 2004, 12:20 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please post your code. also read this FAQ.

http://adopenstatic.com/faq/80040e21.asp

 
Old November 22nd, 2004, 12:24 PM
Authorized User
 
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to don baroo Send a message via Yahoo to don baroo
Default

This is the code.

Please help me out.

Thanks.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Add New Data</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body bgcolor="#DBFFBF">
<body>

 <form action="newdata.asp" method="post" name="form" target="_self">
     First Name:
       <input type="text" name="firstname" maxlength="20">
     <br>
     Last Name: <input type="text" name="lastname" maxlength="20">
     <br>
     ID Number: <input type="text" name="idnumber" maxlength="10">
     <br>
     Email: <input type="text" name="email" maxlength="40">
     <br>

     <input type="submit" name="Submit" value="Submit">
</form>


<%
'Dimension variablesDim adoCon
Dim adoCon 'Holds the Database Connection ObjectDim rsAddstudent
Dim rsAddstudent 'Holds the recordset for the new record to be addedDim strSQL
Dim strSQL 'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;pwd=;database=St udents"

'Create an ADO recordset object
Set rsAddstudent = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM student;"

'Set the cursor type we are using so we can navigate through the recordset
rsAddstudent.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddstudent.LockType = 3

'Open the recordset with the SQL query
rsAddstudent.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rsAddstudent.AddNew

'Add a new record to the recordset
rsAddstudent.Fields("FirstName") = Request.Form("firstname")
rsAddstudent.Fields("LastName") = Request.Form("lastname")
rsAddstudent.Fields("email") = Request.Form("email")
rsAddstudent.Fields("IDNumber") = Request.Form("idnumber")

'Write the updated recordset to the database
rsAddstudent.Update

'Reset server objects
rsAddstudent.Close
Set rsAddstudent = Nothing
Set adoCon = Nothing

'Redirect to the guestbook.asp page
Response.Redirect "test_new.asp"
%>

</body>
</html>


 
Old November 22nd, 2004, 12:43 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

I was plagued by errors such as this one when migrating a project to MySQL some time ago - updating / adding with recordsets seems to chuck errors randomly, something to do with the cursor type & MyODBC / ADO.

In the end I just executed UPDATE and INSERT sql statements instead of using recordsets and these never seem to return errors, although I heard somewhere that using a client side cursor might solve the problem.

HTH,

Chris

 
Old November 22nd, 2004, 12:55 PM
Authorized User
 
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to don baroo Send a message via Yahoo to don baroo
Default

Hi,

Can anyone tell me what is wrong with this code. I get an error message:

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CheckString'
/newdata.asp, line 31

Here is the code.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Add New Data</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body bgcolor="#DBFFBF">
<body>
<p>
  <%
Dim DB, strSQL
Set DB = Server.CreateObject ("ADODB.Connection")
DB.Open "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;pwd=;database=St udents"
Dim RS
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open "SELECT * FROM student", DB
Dim strFirstName, strLastName, stremail, strIDNumber

    strFirstName = Request("FirstName")
    strLastName = Request("LastName")
    stremail = Request("email")
    strIDNumber = Request("IDNumber")


    strSQL = "UPDATE student " & _
             " SET FirstName = " & CheckString(strFirstName, ",") & _
             " LastName = " & CheckString(strLastName, ",") & _
             " email = " & CheckString(stremail, ",") & _
             " IDNumber = " & CheckString(strIDNumber, ",")

    Set DB = Server.CreateObject("ADODB.Connection")
    ' -- Open the Connection
    DB.Open strConnection

        ' - Execute
        DB.Execute (strSQL)

        DB.Close
        set DB = Nothing


%>

<form name="form1" method="post" action="">
  <table width="421" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td width="92"><span class="style1">First Name: </span></td>
      <td width="315"><input name="firstname" type="text" id="firstname"></td>
    </tr>
    <tr>
      <td><span class="style1">Last Name</span>: </td>
      <td><input name="lastname" type="text" id="lastname"></td>
    </tr>
    <tr>
      <td class="style1">email:</td>
      <td><input name="email" type="text" id="email"></td>
    </tr>
    <tr>
      <td><span class="style1">ID Number: </span></td>
      <td><input name="IDNumber" type="text" id="IDNumber"></td>
    </tr>
  </table>


  <p>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">
</p>
</form>
<p>&nbsp;</p>
</body>
</html>


Please help me out.

Thanks.

 
Old November 22nd, 2004, 01:14 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Have you created a CheckString function?


 
Old November 22nd, 2004, 01:22 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not see a function defined in your code or an include..?
I think you are intended to use it to handle apostrophe.









Similar Threads
Thread Thread Starter Forum Replies Last Post
Database unable to show result. (ASP.NET C#) richie86 ASP.NET 1.0 and 1.1 Basics 3 November 10th, 2005 01:59 PM
asp-mysql update error chidomen Classic ASP Databases 1 June 15th, 2005 05:29 PM
Update asp-access to mysql karib Classic ASP Databases 3 November 30th, 2003 01:44 PM
Unable to update database on server senthilpr_in Access ASP 1 September 23rd, 2003 11:43 PM
Unable to update database on server senthilpr_in Classic ASP Databases 0 September 8th, 2003 04:32 PM





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