- Joined
- Mar 27, 2008
- Messages
- 1
- Reaction score
- 0
Dear all,
I am having problems with the code below. I am trying to access a Stored Procedure in the SQL Server 2005 with VB.net.
I get the following error when I try to execute the line
Anyone could please help me?
I am having problems with the code below. I am trying to access a Stored Procedure in the SQL Server 2005 with VB.net.
Code:
Dim conexaoBD As String
conexaoBD = "dsn=Base_Servidor_S&S;uid=sa;pwd=sislg#03"
Dim conn As OdbcConnection = New OdbcConnection(conexaoBD)
Dim cmd As OdbcCommand = conn.CreateCommand
cmd.CommandText = "pr_ss_pesquisaDadosUc"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OdbcParameter("@codigo_uc", OdbcType.Char, 20)).Direction = ParameterDirection.Input
'cmd.Parameters.Add("", Odbc.OdbcType.Char, _
' 20).Direction = ParameterDirection.Input
'cmd.Parameters("@codigo_uc").Value = "000000000106"
cmd.Parameters(0).Value = "000000000106"
Try
conn.Open()
' cmd.ExecuteNonQuery()
Dim dr As OdbcDataReader = cmd.ExecuteReader
If dr.Read Then
'Me.leituras_dataHoraAquisicao = BancoDeDados.DBdatetime(dr.Item("DATA_HORA_AQUISICAO"))
Else
End If
dr.Close()
conn.Close()
'Return aluno
Catch ex As SqlException
Throw New ApplicationException("Erro : " & Microsoft.VisualBasic.Chr(10) & "" + ex.Message)
End Try
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function 'pr_ss_pesquisaDadosUc' expects parameter '@codigo_uc', which was not supplied.
Code:
Dim dr As OdbcDataReader = cmd.ExecuteReader
Anyone could please help me?