Execute a Stored Procedure using ODBC with Parameters

I'm trying to execute a stored procedure using ODBC which has a parameter, but each time I do I get the following:

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function 'aaPRO_CloseCall' expects parameter '@FaultID', which was not supplied.

My code is:

Dim I As Integer = Convert.ToInt32(LogIDTextBox.Text)
Dim ConnString As String = "Dsn=Test"
Dim Conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnString)
Dim cmd As New Odbc.OdbcCommand("aaPRO_closecall", Conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@FaultID", I)
Conn.Open()
cmd.ExecuteNonQuery()
Conn.Close()

I'm new to Visual Studio and I can't see what I've got wrong. I'd be very grateful if anyone can help.

Answers


This is what I did in the end

         'Create the ODBC connection
        Dim Conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnString)
        Conn.Open()

        'Add the call to the stored procedure including the connection
        Dim cmd As New Odbc.OdbcCommand("{ CALL aaPRO_closecall(?) }", Conn)
        cmd.CommandType = CommandType.StoredProcedure

        'add the parameter to the stored procedure
        Dim MyParm As OdbcParameter = cmd.Parameters.Add("@FaultID", OdbcType.Int)
        MyParm.Value = FL

        'Execute the procedure
        cmd.ExecuteNonQuery()

        'clean up after
        Conn.Close()
        Conn.Dispose()

Thanks for your help.


Need Your Help

SP2013 breadcrumbs work but do not display an image

sharepoint-designer

I have enabled Breadcrumps in Sharepoint 2013 and they are working when I click where it should be. The problem is that there is not an image. Can anyone tell me where this image is located or why it

What is the lib/algorithm for matching multiple regular expression against a single target string in C?

c regex algorithm pattern-matching string-matching

I want to match multiple regular expressions against a single string & stop when the first regular expression matches.