ADO.net Visual Studio Parameter Query Question

I am having difficulty integrating parameter queries into my ado.net/vb.net project (2003 version). I get the following error message from the following code
Error" Additional information: The OdbcParameterCollection only accepts non-null OdbcParameter type objects, not SqlParameter objects."

My goal is to check for the existence of a customer master record before adding another one. I was told the ODBCCommands would be the best way here, but I'm having difficulty getting the parm query to run and check for existence of the record so I can proceed with what to do next.

I apologize if this is in the knowledge-base and I've missed it.
Thanks for your help



-------------------------------
        Dim odbccn1 = New OdbcConnection(sConnection)
        Dim cmdselect = New OdbcCommand("select * from customer_master where custid=?", odbccn1)
        cmdselect.commandtype = CommandType.Text
        Dim odbcda1 = New OdbcDataAdapter
        odbcda1.selectcommand = cmdselect
        Dim workParam As New SqlParameter("@CustID", SqlDbType.NChar, 5)
        workParam.Direction = ParameterDirection.Output
        cmdselect.Parameters.Add(workParam)
        cmdselect.Parameters("@CustID").Value = 1111
        Dim ds = New DataSet
        Try
            odbcda1.fill(ds.stable)
        Catch exc As System.Exception
            MsgBox(exc.Message)
        End Try

sny23vpbAsked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
You need to use the OdbcParameter object rather than the SqlParameter.
0
 
sny23vpbAuthor Commented:
Thanks. I changed it to the following but still get this error  " Additional information: The OdbcParameterCollection only accepts non-null OdbcParameter type objects, not SqlParameter objects."

Thanks for any thoughts on this

-------------------------------------------

Imports System.Data.Odbc

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim odbccn1 = New OdbcConnection(sConnection)
        Dim cmdselect = New OdbcCommand("select * from customer_master where custid=?", odbccn1)

        cmdselect.commandtype = CommandType.Text
        Dim odbcda1 = New OdbcDataAdapter

        odbcda1.selectcommand = cmdselect

        Dim workParam As New OdbcParameter("@CustID", OdbcType.NChar, 5)


        workParam.Direction = ParameterDirection.Output

        cmdselect.Parameters.Add(workParam)

        cmdselect.Parameters("@CustID").Value = 1111

        Dim ds = New DataSet
        Try
            odbcda1.fill(ds.stable)
        Catch exc As System.Exception
            MsgBox(exc.Message)
        End Try
    End Sub
0
 
sny23vpbAuthor Commented:
had a few issues with my datasets and adapters but that seems to have resolved it; Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.