?
Solved

ADO.net Visual Studio Parameter Query Question

Posted on 2006-05-05
3
Medium Priority
?
1,025 Views
Last Modified: 2012-08-13
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

0
Comment
Question by:sny23vpb
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 700 total points
ID: 16616109
You need to use the OdbcParameter object rather than the SqlParameter.
0
 

Author Comment

by:sny23vpb
ID: 16619695
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
 

Author Comment

by:sny23vpb
ID: 16619741
had a few issues with my datasets and adapters but that seems to have resolved it; Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question