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