Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-10
22
Medium Priority
?
1,134 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 560 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 560 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 560 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 440 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

705 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