Print Page | Close Window

Database insertion error - Please help!

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10602
Printed Date: 30 March 2026 at 12:09pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Database insertion error - Please help!
Posted By: camds
Subject: Database insertion error - Please help!
Date Posted: 25 May 2004 at 4:30pm

I am trying to insert a new record into a database containing data captured from a form. I am repeatedly getting an error, and can't seem to resolve it. Please help! Thanks for your time...

Microsoft OLE DB Provider for ODBC Drivers error '80040e57' [Microsoft][ODBC Microsoft Access Driver]Numeric value out of range (null) /xsignupform.asp, line 653


Here is the code I am using for the database insertion:

Dim oConn, sSQL
Dim connectstr, sDSNDir
Dim dsn_name, fieldname, tablename
Dim firstname, lastname, company, telephone, email, currentprovider, callspeople, callslength, cardtype, cardnumber, cardexpiration, cardsecnumber, cardfullname, cardzip, address1, address2, city, sstate, zip, recommend

firstname = Request.Form("firstname")
lastname = Request.Form("lastname")
company = Request.Form("company")
telephone = Request.Form("telephone")
email = Request.Form("email")
currentprovider = Request.Form("conference")
callspeople = Request.Form("callspeople")
callslength = Request.Form("callslength")
cardtype = Request.Form("cardtype")
cardnumber = Request.Form("cardnumber")
cardexpiration = Request.Form("cardexpiration")
cardsecnumber = Request.Form("security")
cardfullname = Request.Form("cardfullname")
cardzip = Request.Form("cardzip")
address1 = Request.Form("address1")
address2 = Request.Form("address2")
city = Request.Form("city")
sstate = Request.Form("state")
zip = Request.Form("zipcode")
recommend = Request.Form("recommend")

sSQL = "INSERT into UserData (firstname, lastname, company, telephone, email, currentprovider, callspeople, callslength, cardtype, cardnumber, cardexpiration, cardsecnumber, cardfullname, cardzip, address1, address2, city, sstate, zip, recommend) values ('" & _
 firstname & "', '" & lastname & "', '" & company & "', '" & telephone & "', '" & email & "', '" & currentprovider & "', '" & callspeople & "', '" & callslength & "', '" & cardtype & "', '" & cardnumber & "', '" & cardexpiration & "', '" & cardsecnumber & "', '" & cardfullname & "', '" & cardzip & "', '" & address1 & "', '" & address2 & "', '" & city & "', '" & sstate & "', '" & zip & "', '" & recommend & "')" 
 
dsn_name = "access_data.dsn"
fieldname = "firstname"
tablename = "UserData"

sDSNDir = Server.MapPath("_dsn")
connectstr = "filedsn=" & sDSNDir & "\" & dsn_name

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr 
 
oConn.execute(sSQL)
 
oConn.Close
Set oConn = Nothing




Replies:
Posted By: Semikolon
Date Posted: 26 May 2004 at 4:13am

Numeric value out of range (null)

check all your integer values and see if they fit into the db field



Posted By: psycotik
Date Posted: 26 May 2004 at 6:49am

change this line:

oConn.execute(sSQL)

to:

Response.Write sSQL

oConn.execute(sSQL)

You will alteast then be able to see by looking through the code where the error is.



Posted By: Mart
Date Posted: 26 May 2004 at 11:13am

Is this MSSQL or Access? If it's MSSQL I would use a stored procedure instead so you don't waste time worrying about SQL Injections (Which are possible with the code you posted - I would review it) and it looks much tidier



Posted By: Semikolon
Date Posted: 26 May 2004 at 1:20pm
ODBC Microsoft Access Driver

It's probably Access


Posted By: Mart
Date Posted: 26 May 2004 at 1:32pm
In that case do a google for "SQL Injections" and look how you can prevent them and what they could do


Posted By: camds
Date Posted: 26 May 2004 at 4:02pm
Great, thanks guys. I will research. If you have any other ideas, please let me know...



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net