Monday, March 26, 2012
Error Passing Paramater
I am trying to open a crystal report from VB. Everything works fine.
When I am trying to assign a date parameter value, I get the error "Type Mismatch".
ie. txtdate="14/06/2004"
Report.ParameterFields(1).AddCurrentValue txtdate
where txtdate is a date variable.
I also tried cdate(txtdate)
when I try to pass variables other than type date it works fine.
Regards ,
SatishHi,
I passed a value from a DTPicker control. It works fine. Check the datatype which you have set while parameter creation. It'll work.
And try DTPicker. I used the same code as yours.
Report.ParameterFields(1).AddCurrentValue DTP1.Value
Regards,
harmonycitra|||Hi,
When passing the date make sure that the date is of the format of the system date.
Madhivanan
Thursday, March 22, 2012
Error on Passing parameter to stored procedure
I have a procedure that will save to table in sql server 200 via stored procedure. When I hit the save button it alwasy give me an error saying "Procedure 'sp_AddBoard' expects parameter '@.dtmWarrantyStart', which was not supplied" even though I supplied it in the code
which is
Dim ParamdtmWarrantyStart As SqlParameter = New SqlParameter("@.dtmWarrantyStart", SqlDbType.datetime, 8)
ParamdtmWarrantyStart.Value = dtmWarrantyStart
myCommand.Parameters.Add(ParamdtmWarrantyStart)
below is the stored procedure.
create Proc sp_AddBoard(@.BrandID int,
@.strPcName varchar(50),
@.bitAccounted bit,
@.dtmAccounted datetime,
@.dtmWarrantyStart datetime,
@.dtmWarrantyEnd datetime,
-- @.strDescription varchar(500),
@.intStatus int,
@.ModelNo varchar(50),
@.intMemorySlots int,
@.intMemSlotTaken int,
@.intAgpSlots int,
@.intPCI int,
@.bitWSound bit,
@.bitWLan bit,
@.bitWVideo bit,
@.dtmAcquired datetime,
@.stat bit output,
@.intFSB int) as
if not exists(select strPcName from tblBoards where strPcName=@.strPcName)
begin
insert into tblBoards
(BrandID, strPcName, bitAccounted,
dtmAccounted, dtmWarrantyStart,
dtmWarrantyEnd, --strDescription,
intStatus,
ModelNo, intMemorySlots, intMemSlotTaken,
intAgpSlots, intPCI, bitWLan,
bitWVideo, dtmAcquired,intFSB,bitWSound)
values
(@.BrandID,@.strPcName,@.bitAccounted,
@.dtmAccounted,@.dtmWarrantyStart,
@.dtmWarrantyEnd,--@.strDescription,
@.intStatus,
@.ModelNo,@.intMemorySlots,@.intMemSlotTaken,
@.intAgpSlots,@.intPCI,@.bitWLan,
@.bitWVideo,@.dtmAcquired,@.intFSB,@.bitWSound)
end
else
begin
set @.stat=1
end
The table is also designed to accept nulls on that field but still same error occured.
Please helpjust check if there is any value in the parameter value. the way i normally do is :
myCommand.Parameters.Add(New SqlParameter("@.cusbday",SqlDbType.datetime))
If len(trim(bday.Text)) = 0 Then
myCommand.Parameters("@.cusbday").Value = SqlDateTime.null
Else
myCommand.Parameters("@.cusbday").Value = DateTime.Parse(bday.Text)
End If
also you need to import the namespace System.Data.SqlTypes to use sqldatetime.null
<%@. import Namespace="System.Data.SqlTypes" %>
hthsql