Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2004-09-10
22
1,094 Views
Last Modified: 2012-05-05
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
Comment
Question by:flakymammy
  • 8
  • 7
  • 5
  • +1
22 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12028850
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
 
LVL 15

Expert Comment

by:joeposter649
ID: 12029158
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
 

Author Comment

by:flakymammy
ID: 12029221
when I add the commas I get the error message "wrong number of arguments or invalid property assignment: 'parameters.createparameter'"
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:flakymammy
ID: 12029265
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12029379
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
 
LVL 15

Assisted Solution

by:joeposter649
joeposter649 earned 140 total points
ID: 12029531
Sorry bout the comma thing.

Should Pwsd be Pswd?  I notice you assign it to curPswd.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12029544
>>Sorry bout the comma thing.<<

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

FtB
0
 

Author Comment

by:flakymammy
ID: 12029692
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12029731
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
 
LVL 15

Assisted Solution

by:joeposter649
joeposter649 earned 140 total points
ID: 12029808
Also, you'll probably need to change
curPswd = .Parameters("@Pwsd")
to
curPswd = cmdStoredProc.Parameters("@Pswd")
0
 

Author Comment

by:flakymammy
ID: 12029847
I ran the following executable successfully through Query Analyzer and was successful. Also, I updated the parameter as Joe suggested. Still no success.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12029853
What text did you drop into the query analyzer exactly please?

FtB
0
 

Author Comment

by:flakymammy
ID: 12029866
Oops, meant to include that...

EXECUTE usp_PswdForget '875', '99999', '02', '1234567890'
0
 

Author Comment

by:flakymammy
ID: 12029895
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
 
LVL 15

Assisted Solution

by:joeposter649
joeposter649 earned 140 total points
ID: 12030011
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
 
LVL 15

Expert Comment

by:joeposter649
ID: 12030030
Or Use adParamReturnValue instead of adParamOutput.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12030063
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 12035159
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
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 110 total points
ID: 12035196
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12035405
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
 

Author Comment

by:flakymammy
ID: 12043374
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
 

Author Comment

by:flakymammy
ID: 12043637
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question