The precision is invalid

S

shank

Using Dreamweaver, I'm trying to update a table using a stored procedure.
I'm getting the following error. The line# reference is on the last line:
rsUpdate.Execute(). That doesn't help much, but I'm sure the problem must be
with the number fields: Royalty (money) or Ownership (float). How do I
change the precision to match the table? In this line: "@Royalty", 6,
1,8,varRoyalty, what does 6,1,8 represent. Where can I find a
crossreference? I believe 6 is datatype money, 8 is size in bytes. What is
1...?
thanks

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

<%
set rsUpdate = Server.CreateObject("ADODB.Command")
rsUpdate.ActiveConnection = ConnString
rsUpdate.CommandText = "stp_Publisher_Update"
rsUpdate.CommandType = 4
rsUpdate.CommandTimeout = 0
rsUpdate.Prepared = true
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Title", 200,
1,255,varTitle)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Artist", 200,
1,255,varArtist)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Gender", 200,
1,1,varGender)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Genre", 200,
1,50,varGenre)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@VocalRange", 200,
1,20,varVocalRange)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@GroupLevel", 200,
1,20,varGroupLevel)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@YearReleased", 200,
1,4,varYearReleased)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Agent", 200,
1,50,varAgent)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Publisher", 200,
1,50,varPublisher)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Royalty", 6,
1,8,varRoyalty)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Owner", 200,
1,50,varOwner)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Ownership", 131,
1,9,varOwnership)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Writers", 200,
1,255,varWriters)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Comments", 200,
1,8000,varComments)
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@ID", 131, 1,9,varID)
rsUpdate.Execute()
%>
 
S

shank

Thanks, but I still don't see how to set the Precision property.
I don't see anything that relates to:
rsUpdate.Parameters.Append rsUpdate.CreateParameter("@Royalty", 6,
1,8,varRoyalty)
 
B

Bob Barrows [MVP]

It needs to be set AFTER the Parameter is created:

Set param = rsUpdate.CreateParameter("@Royalty", 6,1)
param.precision = whatever
param.numericscale=whatever
param.value = varRoyalty
rsUpdate.Parameters.Append param

Bob Barrows
 
B

Bob Barrows [MVP]

You do not have any output parameters, so you do not need a Command object:

set cn = server.createobject("adodb.connection")
cn.stp_Publisher_Update varTitle, varArtist, varGender, ..., varID


If you wish to persist in using the Command object, then you would probably
benefit from my Stored procedure code Generator available from:
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp

Bob Barrows
 
B

Bob Barrows [MVP]

shank said:
what does 6,1,8
represent. Where can I find a crossreference?
msdn.microsoft.com/library
Go to Data Access and drill down until you get to te ADO Reference
 
S

shank

I tried your code generator (which is very cool) but got the following
error:
ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
.CommandType=adcmdstoredproc <-- This is the line causing the error
Can you suggest why?
thanks

<%
Dim cmd, param

Set cmd=server.CreateObject("ADODB.Command")
With cmd
.CommandType=adcmdstoredproc <-- error
.CommandText = "stp_Publisher_Update"
set .ActiveConnection=MM_BottomLine_STRING
set param = .createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
.parameters.append param
set param = .createparameter("@Title", adVarChar, adParamInput, 255,
varTitle)
.parameters.append param
set param = .createparameter("@Artist", adVarChar, adParamInput, 255,
varArtist)
.parameters.append param
set param = .createparameter("@Gender", adVarChar, adParamInput, 50,
varGender)
.parameters.append param
set param = .createparameter("@Genre", adVarChar, adParamInput, 50,
varGenre)
.parameters.append param
set param = .createparameter("@VocalRange", adVarChar, adParamInput, 50,
varVocalRange)
.parameters.append param
set param = .createparameter("@GroupLevel", adVarChar, adParamInput, 50,
varGroupLevel)
.parameters.append param
set param = .createparameter("@YearReleased", adVarChar, adParamInput, 4,
varYearReleased)
.parameters.append param
set param = .createparameter("@Agent", adVarChar, adParamInput, 255,
varAgent)
.parameters.append param
set param = .createparameter("@Publisher", adVarChar, adParamInput, 50,
varPublisher)
.parameters.append param
set param = .createparameter("@Royalty", adCurrency, adParamInput, 0,
varRoyalty)
.parameters.append param
set param = .createparameter("@Owner", adVarChar, adParamInput, 50,
varOwner)
.parameters.append param
set param = .createparameter("@Ownership", adNumeric, adParamInput, 0,
varOwnership)
param.precision=18
param.numericscale=0
.parameters.append param
set param = .createparameter("@Writers", adVarChar, adParamInput, 255,
varWriters)
.parameters.append param
set param = .createparameter("@Comments", adVarChar, adParamInput, 8000,
varComments)
.parameters.append param
set param = .createparameter("@ID", adNumeric, adParamInput, 0, varID)
param.precision=18
param.numericscale=0
.parameters.append param
.execute ,,adexecutenorecords
end with
%>
 
B

Bob Barrows [MVP]

Yes. Your version of adovbs.inc does not include the declaration for the
acmdstoredproc constant. You can add the declaration yourself:

Const adCmdStoredProc = &H0004

Bob Barrows
 
S

shank

That wasn't it. It was in the adovbs.inc file.
thanks
'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004 <----
Const adCmdFile = &H0100
Const adCmdTableDirect = &H0200
 
B

Bob Barrows [MVP]

Then it's a different line raising the error. The problem is the same: and
undeclared constant. Could it be the adExecuteNoRecords constant? That
should be:

Const adExecuteNoRecords = 128

Bob Barrows
 
B

Bob Barrows [MVP]

Oh, wait! I see the problem:

set .ActiveConnection=MM_BottomLine_STRING

You can't use Set when setting the activeconnection property to a string.
..ActiveConnection=MM_BottomLine_STRING


You would be better off creating an explicit connection object in any case:

set cn=server.createobject("adodb.connection")
cn.open MM_BottomLine_STRING
'hopefully, that string does not use ODBC
set .ActiveConnection=cn

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top