Store Procedure with VB.net
Personnel
Good night, created a store procedure below the Oracle 11g, I am testing, and I am trying to access the VB.net 2008, and giving this as an error, this just below the program, check what can be, or check which would be the best way, by 2008 vb.net I have access to store procedure below.
create or replace PROCEDURE "INC_EMPRESAS"(
pCodigo IN NUMBER
, pNome IN VARCHAR2
, pEndereco IN VARCHAR2
, pCEP IN VARCHAR2
) AS
BEGIN
insert into empresas (cod_emp,nom_emp,end_emp,cep_emp)
values (pCodigo,pNome,pEndereco,pCEP);
END INC_EMPRESAS;
Dim banco_odbc As String = "Driver={Microsoft ODBC for Oracle};Server=orcl;Uid=system;Pwd=nanda;"
Dim cd_retorno As Integer = 0
Dim cod_cliente As Integer = 122221
Dim nom_cliente As String = "NOME DA EMPRESA"
Dim end_cliente As String = "ENDERECO DA EMPRESA"
Dim cep_cliente As String = "12345678"
Dim conexao As New OdbcConnection(banco_odbc)
Dim cmd As New OdbcCommand()
Try
cmd.Connection = conexao
With cmd
.CommandText = "INC_EMPRESAS"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@pCodigo", OdbcType.Numeric, 8).Value = cod_cliente
.Parameters(0).Direction = ParameterDirection.Input
.Parameters.Add("@pNome", OdbcType.VarChar, 50).Value = nom_cliente
.Parameters(1).Direction = ParameterDirection.Input
.Parameters.Add("@pEndereco", OdbcType.VarChar, 50).Value = end_cliente
.Parameters(2).Direction = ParameterDirection.Input
.Parameters.Add("@pCEP", OdbcType.VarChar, 8).Value = cep_cliente
.Parameters(3).Direction = ParameterDirection.Input
End With
conexao.Open()
Try
cmd.ExecuteNonQuery()
TextBox1.Text = "Completado com sucesso"
Catch ex As Exception
TextBox1.Text = "erro"
End Try
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
conexao.Close()
A first chance exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
The program '[3216] Aplicacao.vshost.exe: Managed' has exited with code 0 (0x0).
Thank you for your help now
Claudinei
nei@brazul.com.br