Advertisement

07.30.2008 at 09:58AM PDT, ID: 23608113
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.1

"The precision is invalid" error - ASP Classic/VBScript/SQL Server

Asked by saoirse1916 in Active Server Pages (ASP), MS SQL Server, VB Script

Tags:

I'm using a stored procedure and a parameterized command to insert into my database.  I'm a bit new at using parameterized input so I'm hoping that I'm just missing something simple here.  I'm running into a problem with my numeric (and possibly float) data types during the insert.  The error that I'm getting is "The precision is invalid."  After investigating this I found out that I need to specify precision and scale and I believe that I'm doing it correctly but I'm not positive.  Here's what I've got so far:

Dim insertBuildingCmd, insertBuildingParam
Set insertBuildingCmd = Server.CreateObject("ADODB.Command")
insertBuildingCmd.ActiveConnection = DB_CONN_STRING
insertBuildingCmd.CommandText = "sproc_building_insert"
insertBuildingCmd.CommandType = 4

'      Set parameters
Set insertBuildingParam = insertBuildingCmd.CreateParameter("@Name",200,1,500)
insertBuildingCmd.Parameters.Append insertBuildingParam
insertBuildingCmd.Parameters("@Name") = Request.Form("formName")
Set insertBuildingParam = Nothing

(...several more text parameters)

Set insertBuildingParam = insertBuildingCmd.CreateParameter("@Lat",5,1,8)
insertBuildingCmd.Parameters.Append insertBuildingParam
If Request.Form("formLat") <> "" Then
      insertBuildingCmd.Parameters("@Lat") = Request.Form("formLat")
      insertBuildingCmd.Parameters("@Lat").Precision = 53
Else
      insertBuildingCmd.Parameters("@Lat") = Null
End If
Set insertBuildingParam = Nothing

Set insertBuildingParam = insertBuildingCmd.CreateParameter("@GLA",131,1,9)
insertBuildingCmd.Parameters.Append insertBuildingParam
If Request.Form("formGLA") <> "" Then
      insertBuildingCmd.Parameters("@GLA") = Request.Form("formGLA")
      insertBuildingCmd.Parameters("@GLA").Precision = 18
      insertBuildingCmd.Parameters("@GLA").NumericScale = 2
Else
      insertBuildingCmd.Parameters("@GLA") = Null
End If
Set insertBuildingParam = Nothing

(...quite a few more numeric parameters)

I wasn't sure if the float datatypes needed precision/scale information so I've tried it with and without and I still get the same error.  On the chance that the parameter had to be appended *after* the Precision/Scale declarations, I've also tried rewriting the parameters as:

Set insertBuildingParam = insertBuildingCmd.CreateParameter("@GLA",131,1,9)
If Request.Form("formGLA") <> "" Then
      insertBuildingCmd.Parameters("@GLA") = Request.Form("formGLA")
      insertBuildingCmd.Parameters("@GLA").Precision = 18
      insertBuildingCmd.Parameters("@GLA").NumericScale = 2
Else
      insertBuildingCmd.Parameters("@GLA") = Null
End If
insertBuildingCmd.Parameters.Append insertBuildingParam
Set insertBuildingParam = Nothing

But all that gets me is an "Item cannot be found in the collection corresponding to the requested name or ordinal." error.

Can anyone point me in the right direction?  Thanks very much!
Start Free Trial
[+][-]07.30.2008 at 10:23AM PDT, ID: 22122608

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 10:40AM PDT, ID: 22122770

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 10:46AM PDT, ID: 22122824

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 11:01AM PDT, ID: 22122952

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 11:09AM PDT, ID: 22123012

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), MS SQL Server, VB Script
Tags: VBScript / ASP / SQL Server
Sign Up Now!
Solution Provided By: acperkins
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.30.2008 at 11:11AM PDT, ID: 22123032

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 11:47AM PDT, ID: 22123389

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 06:09PM PDT, ID: 22126176

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 07:24AM PDT, ID: 22129967

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628