• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1275
  • Last Modified:

ASP page error "Microsoft OLE DB Provider for SQL Server error '80004005' The precision is invalid."

Please forgive my ignorance...I'm just learning ASP and this is my very first project.

Receiving error "Microsoft OLE DB Provider for SQL Server error '80004005'  The precision is invalid." when running page. It's referencing my Execute line.

Thanks in advance for any assistance you can offer.

My script follows...

<%@LANGUAGE="VBSCRIPT"%>
<%Option Explicit%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"

Const adCmdStoredProc    = 4
Const adChar       = 129
Const adInteger          = 3
Const adNumeric       = 131
Const adParamInput       = 1
Const adParamOutput      = 2

Dim cnnStoredProc
Dim cmdStoredProc
Dim rstStoredProc
Dim curPswd
Dim frmUsername, frmZip, frmBirthMonth, frmHomePhone
Dim pswd

frmUsername = trim(Request.Form("Username"))
frmZip = trim(Request.Form("Zip"))
frmBirthMonth = trim(Request.Form("BirthMonth"))
frmHomePhone = trim(Request.Form("HomePhone"))

Set cnnStoredProc = Server.CreateObject("ADODB.Connection")
cnnStoredProc.Open "Provider=SQLOLEDB.1;User ID=****;Password=****;Initial Catalog=StdEml;Data Source=Jenz"
Set cmdStoredProc = Server.CreateObject("ADODB.Command")
cmdStoredProc.activeConnection = cnnStoredProc
cmdStoredProc.CommandText = "usp_PswdForget"
cmdStoredProc.CommandType = adCmdStoredProc

response.Write "Returning pswd for: " & frmUsername & ", " & frmZip & ", " & frmBirthMonth & ", " & frmHomePhone

cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Username",adInteger,adParamInput,,frmUsername)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Zip",adChar, adParamInput,12,frmZip)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@BirthMonth",adChar,adParamInput,2,frmBirthMonth)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@HomePhone",adNumeric,adParamInput,,frmHomePhone)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Pwsd",adChar,adParamOutput,15)

Set rstStoredProc = cmdStoredProc.Execute()
curPswd = .Parameters("@Pwsd")

Response.Write "It returned a recordset which I used " _
      & "to print out this password: "

Response.Write (curPswd)

Set rstStoredProc = Nothing
Set cmdStoredProc = Nothing

cnnStoredProc.Close
Set cnnStoredProc = Nothing
%>
0
flakymammy
Asked:
flakymammy
  • 8
  • 7
  • 5
  • +1
4 Solutions
 
fritz_the_blankCommented:
Is it possible that you are passing values too large for fields, i.e., something larger than 2 digits for birth month and etc.?

FtB
0
 
joeposter649Commented:
You need extra commas to hold the place for the precisions...
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Zip",adChar, adParamInput,12,,frmZip)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@BirthMonth",adChar,adParamInput,2,,frmBirthMonth)
0
 
flakymammyAuthor Commented:
when I add the commas I get the error message "wrong number of arguments or invalid property assignment: 'parameters.createparameter'"
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
flakymammyAuthor Commented:
fritz,

I'm definitely only entering the required length of characters/digits in each of the html page's fields. Just in case there where extra spaces, though, I trimmed the data in the asp page.
0
 
fritz_the_blankCommented:
I did a quick search the the MSKB (Microsoft Knowledge Base) and every entry I saw pointed towards an attempted insertion of data that was too large or inappropriate for a given field.

Have you tried executing a literal sql insert in your DBMS to make sure things work with the type of data that you are using?

FtB
0
 
joeposter649Commented:
Sorry bout the comma thing.

Should Pwsd be Pswd?  I notice you assign it to curPswd.
0
 
fritz_the_blankCommented:
>>Sorry bout the comma thing.<<

A thousand floggings with a wet noodle! Good catch on the alternative spellings.

FtB
0
 
flakymammyAuthor Commented:
They don't call me flaky for nothing...sadly, though, after cleaning up my misspellings I'm still getting the Precision is Invalid error. I'm going to try your literal sql insert next...here's hoping. I have tried running the stored procedure I'm referencing,m with the variables I'm entering in the html form, through Query Analyzer and all is well. I'm wondering if I'm just going about this whole thing the wrong way. Quite simply, I'm needing to create a basic form which our student's use when they forget their password. They have to enter their Username(id), zip, 2-character birthmonth, and homephone. I need to then verify this against the SQL database and return their password.
0
 
fritz_the_blankCommented:
Try calling the sp from the query analyzer and see what happens. If that works, then we'll move toward figuring out why it doesn't work here.

FtB
0
 
joeposter649Commented:
Also, you'll probably need to change
curPswd = .Parameters("@Pwsd")
to
curPswd = cmdStoredProc.Parameters("@Pswd")
0
 
flakymammyAuthor Commented:
I ran the following executable successfully through Query Analyzer and was successful. Also, I updated the parameter as Joe suggested. Still no success.
0
 
fritz_the_blankCommented:
What text did you drop into the query analyzer exactly please?

FtB
0
 
flakymammyAuthor Commented:
Oops, meant to include that...

EXECUTE usp_PswdForget '875', '99999', '02', '1234567890'
0
 
flakymammyAuthor Commented:
Here's the exact stored procedure...

CREATE PROCEDURE usp_PswdForget
(@JenzID int, @Zip char(12),  @BirthMonth char(2), @HomePhone numeric(10,0))
AS

DECLARE @Pswd char(15)

Select @Pswd = Pswd from dbo.tbl_Main where JenzID = @JenzID and Zip = @Zip and
 BirthMonth = @BirthMonth and HomePhone = @HomePhone

GO
0
 
joeposter649Commented:
I'm not big into SQL Server but I think your sp should look like this...

CREATE PROCEDURE usp_PswdForget
(
@JenzID int,
@Zip char(12),  
@BirthMonth char(2),
@HomePhone numeric(10,0),
@Pswd char(15) OUTPUT
)
AS

Select @Pswd = Pswd from dbo.tbl_Main where JenzID = @JenzID and Zip = @Zip and
 BirthMonth = @BirthMonth and HomePhone = @HomePhone

GO
0
 
joeposter649Commented:
Or Use adParamReturnValue instead of adParamOutput.
0
 
fritz_the_blankCommented:
Okay, this link here says that you need to identify the precision for the numeric parameter:

http://www.devguru.com/Technologies/ado/quickref/command_createparameter.html

0
 
Anthony PerkinsCommented:
Seince you are passing a numeric (10,0) parameter You need to set the Precison and Scale.

Also and unrelated your stored procedure is not returning a recordset, so there is no need to instantiate it.  Change your code to something like this (untested):

cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Username",adInteger,adParamInput,,frmUsername)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Zip",adChar, adParamInput,12,frmZip)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@BirthMonth",adChar,adParamInput,2,frmBirthMonth)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@HomePhone",adNumeric,adParamInput,,frmHomePhone)
cmdStoredProc.parameters(""@HomePhone").Precision = 10
cmdStoredProc.parameters(""@HomePhone").NumericScale = 0
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Pwsd",adChar,adParamOutput,15)

' Set rstStoredProc = cmdStoredProc.Execute()
cmdStoredProc.Execute , , adExecuteNoRecords

curPswd = .Parameters("@Pwsd")

Response.Write "It returned a recordset which I used " _
     & "to print out this password: "

Response.Write (curPswd)

Set rstStoredProc = Nothing
Set cmdStoredProc = Nothing

cnnStoredProc.Close
Set cnnStoredProc = Nothing
%>
0
 
Anthony PerkinsCommented:
Fritz,

Sorry, just saw you had already pointed that out.

flakymammy,
If you can change the HomePhone column from a numeric(10, 0) data type to a char or varchar and likewise the @HomePhone parameter in the stored procedure.  This is what it would look like:

CREATE PROCEDURE usp_PswdForget
(
@JenzID int,
@Zip char(12),  
@BirthMonth char(2),
@HomePhone char(10),
@Pswd char(15) OUTPUT
)
AS

Select @Pswd = Pswd
From dbo.tbl_Main
Where JenzID = @JenzID
          and Zip = @Zip
          and BirthMonth = @BirthMonth
          and HomePhone = @HomePhone

GO

And your ASP code:
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Username", adInteger, adParamInput, , frmUsername)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Zip",adChar, adParamInput, 12, frmZip)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@BirthMonth", adChar,adParamInput, 2, frmBirthMonth)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@HomePhone", adChar,adParamInput, 10, frmHomePhone)
cmdStoredProc.parameters.append cmdStoredProc.createparameter ("@Pwsd", adChar, adParamOutput, 15)
cmdStoredProc.Execute , , adExecuteNoRecords
0
 
fritz_the_blankCommented:
Ah!!! This is what I didn't know how to do:

cmdStoredProc.parameters(""@HomePhone").Precision = 10
cmdStoredProc.parameters(""@HomePhone").NumericScale = 0


In any case, with ACPerkins involved, flakymammy is in good hands!

FtB
0
 
flakymammyAuthor Commented:
Thank goodness for you folks...I've been putzing with how to declare the precision and numericscale...I knew I wasn't doing something right...let me see if this will do it.
0
 
flakymammyAuthor Commented:
Yes! Changing HomePhone to char(10) in my table, stored procedure and asp page did the trick. I kept thinking it should be char when I was first designing the database, but I went ahead and mirrored the datatypes in our administrative software system just in case I need to feed data in later...listen to the voices...listen to the voices...

Thanks to all for your outstanding help. I've learned so much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 7
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now