Re: Adding date to parameter



Is there some reason you're using OLE DB instead of SqlClient (and named
parameters)?


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"T McDonald" <TMcDonald@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DF708DCB-FDE9-4742-B3F2-67DC356876FD@xxxxxxxxxxxxxxxx
I'm having a problem inserting a date into a SQL server database using a
parameter. I keep getting the following error:

"Implicit conversion from data type datetime to int is not allowed. Use
the
CONVERT function to run this query."

ClaimedDate is declared as a String. When I run through the debugger,
ClaimedDate does appear to have a properly formatted date.

Parameters(3) = New Data.OleDb.OleDbParameter
Parameters(3).ParameterName = "@WhenClaimed"
Parameters(3).OleDbType = OleDbType.Date

I've tried adding the value with both of the following with no success:
Parameters(3).Value = DateTime.Parse(ClaimedDate)
Parameters(3).Value = CDate(ClaimedDate)

I am using the following stored procedure:

ALTER PROCEDURE [dbo].[spUpdateClaimedBy]
-- Add the parameters for the stored procedure here
@ClaimedBy varchar(50) = 0,
@ClaimedByName varchar(250) = 0,
@WhenClaimed datetime = date,
@Index int = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
UPDATE dbo.Accounts
SET ClaimedBy = @ClaimedBy, ClaimedByName = @ClaimedByName, WhenClaimed =
@WhenClaimed
WHERE [Index] = @Index
END

Any help would be greatly appreciated.


.



Relevant Pages

  • Re: Adding date to parameter
    ... and SqlClient with dates, but I don't think I could rewrite the code in a ... I am using the following stored procedure: ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Adding date to parameter
    ... I made the assumption that the stored procedure went by the @paramtername ... "Implicit conversion from data type datetime to int is not allowed. ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Adding date to parameter
    ... I made the assumption that the stored procedure went by the @paramtername not ... "Implicit conversion from data type datetime to int is not allowed. ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Adding date to parameter
    ... I made the assumption that the stored procedure went by the @paramtername ... "Implicit conversion from data type datetime to int is not allowed. ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Using DTS to Insert 1 Second record for every second in a month?
    ... Okay...so you basically need a calendar table by seconds. ... And yes that will perform pretty fast for the type of query ... >set NoCount OFF ... >This stored procedure took about 21 minutes. ...
    (microsoft.public.sqlserver.dts)