Data type problem, something to do with datatypeEnum??

L

Lukelrc

Hi all.

I'm having trouble connecting to my sql server database correctly
beacause of value type problems, specifically the date fields. When i
try and run the page i get the follwoing error:

'Application uses a value of the wrong type for the current
operation.'

I beleive the problem is releated to DatatypeEnum values. At the
moment i have the date fields set to 135, but whatever i try i cant
seem to it to work.

I would be very greatful if someone could spot where i'm going wrong.



Datatbase connection:


set CmdAddPr = Server.CreateObject("ADODB.Command")
CmdAddPr.ActiveConnection = MM_Intranet_STRING
CmdAddPr.CommandText = "dbo.AddPressRelease"
CmdAddPr.CommandType = 4
CmdAddPr.CommandTimeout = 0
CmdAddPr.Prepared = true
CmdAddPr.Parameters.Append CmdAddPr.CreateParameter("@RETURN_VALUE",
3, 4)
CmdAddPr.Parameters.Append
CmdAddPr.CreateParameter("@pressreleasedescription", 200,
1,250,CmdAddPr__pressreleasedescription)

CmdAddPr.Parameters.Append
CmdAddPr.CreateParameter("@pressreleasedate", 135,
1,20,CmdAddPr__pressreleasedate)

CmdAddPr.Parameters.Append CmdAddPr.CreateParameter("@username", 200,
1,50,CmdAddPr__username)

CmdAddPr.Parameters.Append CmdAddPr.CreateParameter("@lastupdated",
135, 1,20,CmdAddPr__lastupdated)

CmdAddPr.Parameters.Append CmdAddPr.CreateParameter("@filesize", 131,
1,20,CmdAddPr__filesize)

CmdAddPr.Parameters.Append CmdAddPr.CreateParameter("@publish", 128,
1,20,CmdAddPr__publish)
CmdAddPr.Execute()



.....My stored procudure:

CREATE Procedure dbo.AddPressRelease

@pressreleasedescription varchar(250),
@pressreleasedate datetime,
@username varchar(50),
@lastupdated datetime,
@filesize numeric,
@publish bit
As


Declare @pressreleaseid int

Select @pressreleaseid = nextpressreleaseid from nextids

Insert into PressReleases(pressreleaseID,pressreleasedescription,pressreleasedate,username,lastupdated,filesize,publish)
Values (@pressreleaseid,@pressreleasedescription,@pressreleasedate,@username,@lastupdated,@filesize,@publish)

Update nextids set nextpressreleaseid = nextpressreleaseid + 1



return @pressreleaseid
GO



.....and my sql server table:

Data type Length
PressReleaseID int 4
PressReleaseDate datetime 8
Publish bit 1
Username varchar 50
Filesize varchar 50
LastUpdated datetime 8
PressReleaseDescription varchar 255

Thanks in advance,

Luke
 
B

Bob Barrows [MVP]

Lukelrc said:
Hi all.

I'm having trouble connecting to my sql server database correctly
No, you're not. Your connection is happening correctly. Your problem is in
executing your procedure.
beacause of value type problems, specifically the date fields. When i
try and run the page i get the follwoing error:

'Application uses a value of the wrong type for the current
operation.'

I beleive the problem is releated to DatatypeEnum values. At the
moment i have the date fields set to 135, but whatever i try i cant
seem to it to work.

Parameters with the numeric datatype need to have their NumericScale and
Precision properties set.

Coding the Parameters collection can be tricky, and many free code
generators have been developed, including one that i wrote. It is available
here:
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear

In order to use the code created by this generator, you will need to define
the ADO constant enumerations in your web page. One way to do that is to
#include the adovbs.inc file. A better way is shown here:
http://www.aspfaq.com/show.asp?id=2112

HTH,
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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,260
Latest member
kentcasinohelpWilhemina

Latest Threads

Top