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 July 12th, 2004, 08:51 AM
Authorized User
 
Join Date: Jul 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Micr OLE DB Provider for ODBC Drivers (0x80040E14)

Hi I am trying to write values to a database, but when using the INSERT
keyword, i get this error : Number of query values and destination fields
are not the same. I have reduced my number of query values and destination
fields to just one so they are definitely the same. Anyone got any ideas? the code is as follows:

<%
If Len(Request.Form("Company")) = 0 Then
   Response.Redirect("addError.asp")
Else
   Set Conn = Server.CreateObject("ADODB.Connection")
   Conn.Open "DSN=AppsDB"

   Company = ReplaceQuotes(Request.Form("Company"))
' Division = ReplaceQuotes(Request.Form("Division"))
' Device = ReplaceQuotes(Request.Form("Device"))
' Engineer = ReplaceQuotes(Request.Form("Engineer"))
' MainIssue = ReplaceQuotes(Request.Form("MainIssue"))
' DateReceived = ReplaceQuotes(Request.Form("DateReceived"))

   strSql = "INSERT INTO MainTable VALUES('" & Company & "')"
   ', '" & Division & "', '" & Device & "', '" & Engineer & "', '" & MainIssue & "', '" & DateReceived & "')"
   Conn.Execute(strSql)

   Conn.Close
   Set Conn = Nothing
End If

Function ReplaceQuotes(strValue)
   strValue = Replace(strValue, "'", "''")

   ReplaceQuotes = strValue
End Function
%>


 
Old July 12th, 2004, 07:01 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you Response.Write your SQL statement (after posting the form)? Check your database for any missing fields,

The way you have your SQL statements,the values will have to be specified in the order of the fields in the table.
You can also try to build you SQL statement like this
INSERT INTO tablename (column1, column2,column3) VALUES (value1,value2,value3);

Let me know
 
Old July 13th, 2004, 01:34 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

You could try an update query as well.

set rs = server.createobject("adodb.recordset")
sql = "select * from MainTable"
rs.open sql, conn, 3, 3
rs.addnew
rs("Company") = request("Company")
rs("Division") = request("Division")
rs("Device") = request("Device")
rs("Engineer") = request("Engineer")
rs("MainIssue") = request("MainIssue")
rs("DateReceived") = request("DateReceived")
rs.update

 
Old July 13th, 2004, 07:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

When you try to add value to just one or two columns and not all the columns of the table, then you have to mention that in order and specify its values in that order too in your INSERT statement, which you are missing.

strSql = "INSERT INTO MainTable(COMPANY_COLUMN_NAME) VALUES('" & Company & "')"

Regarding the error that you might have faced while trying to add values for all the columns, check if all VARIABLES are having values.

Also check this Page - Why do I get an 0x80040e14 error message? that deals with other errors of similar error code.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 13th, 2004, 09:09 AM
Authorized User
 
Join Date: Jul 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks guys! Its working now!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft OLE DB Provider for ODBC Drivers (0x8004 phantom3008 ASP.NET 1.0 and 1.1 Basics 6 April 25th, 2007 10:30 AM
Microsoft OLE DB Provider for ODBC Drivers phantom3008 Classic ASP Basics 6 March 15th, 2007 09:39 AM
Microsoft OLE DB Provider for ODBC Drivers surendran Classic ASP Databases 4 October 27th, 2003 10:23 AM
OLE DB Provider for ODBC Drivers error '80004005' Routhg Access ASP 2 June 11th, 2003 07:02 AM





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