error converting data type nvarchar to int...  
Author Message
pqjr





PostPosted: Visual Basic General, error converting data type nvarchar to int... Top

...when I try pass date parameter to procedure on SQL 2005

can you help me

Thanks



Visual Basic13  
 
 
DMan1





PostPosted: Visual Basic General, error converting data type nvarchar to int... Top

CODE ERROR MESSAGE

 
 
spotty





PostPosted: Visual Basic General, error converting data type nvarchar to int... Top

The error message would appear fairly self explanatory - you are trying to pass a type nvarchar to a parameter of type integer, porbably calling something like a stored procedure

This wont work. You need to match the parameter type Being declared in the stored procedure with the parameters collection item being passed.

Showing code would definately help.


 
 
cgsdev





PostPosted: Visual Basic General, error converting data type nvarchar to int... Top

This is a Stored Procedure:

ALTER PROCEDURE [dbo].[Proc_ins_Colaboradores]

varchar(80),

Datetime,

Char(1),

Varchar(18),

Varchar(30),

int,

char(1),

int,

int OUTPUT

AS

BEGIN

SET NOCOUNT ON;

INSERT tbl_Colaboradores (str_Nome.........

This is my VB Code:

l_cmm_Comando.Connection = l_cnn_Conexao

l_cmm_Comando.CommandText = "proc_ins_Colaboradores"

l_cmm_Comando.CommandType = CommandType.StoredProcedure

l_cmm_Comando.Parameters.AddWithValue( , str_Nome)

l_cmm_Comando.Parameters.AddWithValue( , dat_Nascimento)

l_cmm_Comando.Parameters.AddWithValue( , str_EstadoCivil)

l_cmm_Comando.Parameters.AddWithValue( , str_Nacionalidade).......

All be DateTime Type, I make a test and put the fixed line in vb code:

l_cmm_Comando.Parameters.AddWithValue( , cdate(Now()))

or

l_cmm_Comando.Parameters.AddWithValue( , Now())

...And I receive the same error:

error converting data type nvarchar to int

Thanks for help !



 
 
spotty





PostPosted: Visual Basic General, error converting data type nvarchar to int... Top

Try using the normal add method and specifying the parameter type.   That way you are specifying the type and size of each of the parameters


        l_cmm_Comando.CommandText = "proc_ins_Colaboradores"
        l_cmm_Comando.CommandType = CommandType.StoredProcedure










 

 

Interesting article

http://msdn2.microsoft.com/en-us/library/yy6y35y8.aspx