invoke stored sql procedure, from vb2005, with parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vernon
    New Member
    • Oct 2006
    • 2

    invoke stored sql procedure, from vb2005, with parameters

    the following code, in a vutton click, successfully calls a stored procedure in sql server..


    Dim strconn As String
    strconn = "Provider=SQLOL EDB;DATA SOURCE=" + sDataSource + ";initial catalog = madisonavenuefu rniture;Trusted _Connection=yes ;"
    Dim cn As New OleDb.OleDbConn ection(strconn)
    cn.Open()
    Dim cmd As New OleDb.OleDbComm and("pPONumberW rite", cn)
    cmd.ExecuteNonQ uery()
    however

    when I amend it to try and pass parameters to the stored procedure, the parameters are not seen...

    Dim strconn As String
    strconn = "Provider=SQLOL EDB;DATA SOURCE=" + sDataSource + ";initial catalog = madisonavenuefu rniture;Trusted _Connection=yes ;"
    Dim cn As New OleDb.OleDbConn ection(strconn)
    cn.Open()
    Dim cmd As New OleDb.OleDbComm and("pPONumberW rite", cn)
    cmd.Parameters. AddWithValue("@ P1", "2")
    'cmd.Parameters .AddWithValue(" @P2", "1649")
    cmd.ExecuteNonQ uery()

    whynot?

    help
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    have you amended the stored procedure to accept the parameters???

    Comment

    • vernon
      New Member
      • Oct 2006
      • 2

      #3
      Originally posted by scripto
      have you amended the stored procedure to accept the parameters???
      yes... believe I have. Executed from object explorer in server managment studio, it asks for parameter value, and works well!

      Comment

      • scripto
        New Member
        • Oct 2006
        • 143

        #4
        well your code looks ok - can we see the stored proc?

        Comment

        Working...