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.
error converting data type nvarchar to int...
Christie Myburgh
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
l_cmm_Comando.Parameters.Add("@str_Nome", SqlDbType.VarChar, 100).SqlValue = "ssss"
l_cmm_Comando.Parameters.Add("@dat_Nascimento", SqlDbType.DateTime).SqlValue = Now
l_cmm_Comando.Parameters.Add("@str_EstadoCivil", SqlDbType.VarChar, 1).SqlValue = "s"
l_cmm_Comando.Parameters.Add("@str_Nacionalidade", SqlDbType.VarChar, 18).SqlValue = "ssss"
l_cmm_Comando.Parameters.Add("@str_Naturalidade", SqlDbType.VarChar, 30).SqlValue = "ssss"
l_cmm_Comando.Parameters.Add("@int_CodProfissao", SqlDbType.Int).SqlValue = 1
l_cmm_Comando.Parameters.Add("@str_Sexo", SqlDbType.Char, 1).SqlValue = "s"
l_cmm_Comando.Parameters.Add("@int_CodGrauInstrucao", SqlDbType.Int).SqlValue = 2
l_cmm_Comando.Parameters.Add("@int_Colaborador", SqlDbType.Int)
l_cmm_Comando.Parameters("@int_Colaborador").Direction = ParameterDirection.Output
Interesting article
http://msdn2.microsoft.com/en-us/library/yy6y35y8.aspx
AlanSweet
Sharath paleri
This is a Stored Procedure:
ALTER
PROCEDURE [dbo].[Proc_ins_Colaboradores]@str_Nome
varchar(80),@dat_Nascimento
Datetime,@str_EstadoCivil Char(1),
@str_Nacionalidade
Varchar(18),@str_Naturalidade
Varchar(30),@int_CodProfissao
int,@str_Sexo
char(1),@int_CodGrauInstrucao
int,@int_Colaborador
int OUTPUTAS
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", str_Nome)l_cmm_Comando.Parameters.AddWithValue(
"@dat_Nascimento", dat_Nascimento)l_cmm_Comando.Parameters.AddWithValue(
"@str_EstadoCivil", str_EstadoCivil)l_cmm_Comando.Parameters.AddWithValue(
"@str_Nacionalidade", str_Nacionalidade).......All be DateTime Type, I make a test and put the fixed line in vb code:
l_cmm_Comando.Parameters.AddWithValue("@dat_Nascimento", cdate(Now()))
or
l_cmm_Comando.Parameters.AddWithValue("@dat_Nascimento", Now())
...And I receive the same error:
error converting data type nvarchar to int
Thanks for help !
wslee
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.