Topic
  • 2 replies
  • Latest Post - ‏2003-09-17T15:32:19Z by SystemAdmin
SystemAdmin
SystemAdmin
3129 Posts

Pinned topic VB.NET stored procedure problem with V5R2

‏2003-09-15T04:11:38Z |
Hi,

I am trying to call stored procedures from VB.NET. I am successful doing
this with V5R1, but it seems that the sintax for some functions have
chnaged. i.e. like the connection string. Can someone send me an example of
a stored proc call and what PTF's I may need for the database on the AS/400.

Thanks

James C. Posey

Updated on 2003-09-17T15:32:19Z at 2003-09-17T15:32:19Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    3129 Posts

    Re: VB.NET stored procedure problem with V5R2

    ‏2003-09-17T02:17:30Z  
    Don't know of any changes - did you double check that you have the latest DB
    Group PTF & iSeries Access Service Pack installed?

    Kent Milligan, DB2 & BI team
    PartnerWorld for Developers, iSeries
    kmill@us.eye-bee-m.com (spam trick) GO HAWKEYES!!
    >>> www.iseries.ibm.com/db2
    (opinions stated are not necessarily those of my employer)
  • SystemAdmin
    SystemAdmin
    3129 Posts

    Re: VB.NET stored procedure problem with V5R2

    ‏2003-09-17T15:32:19Z  
    Yes they do work, but I had to play around quite a bit to make it work via
    the OLEDB provider until a native dot net one is released. I also have yet
    to be able to return an integer from a SP without passing it back through an
    InOut parameter. There are other better ways to write thisd code, but
    here's a real basic VB.Net (2k3) sample for you to build on:

    Dim cn As New OleDbConnection("Provider=IBMDA400;Data
    Source=MySystem;Default Collection = MyAppLib;CATALOG LIBRARY
    LIST=MyAppLib;Persist Security Info=True;")

    Dim da As New OleDbDataAdapter
    Dim nrecs As Integer

    da.SelectCommand = cn.CreateCommand()
    da.SelectCommand.CommandText = "TESTCMD" ' Note: TestCmd in in
    MyAppLib
    da.SelectCommand.CommandType = CommandType.StoredProcedure
    da.SelectCommand.Parameters.Add("DOCID", OleDbType.Integer)
    da.SelectCommand.Parameters("DOCID").Direction =
    ParameterDirection.Input
    da.SelectCommand.Parameters("DOCID").Value = 123456

    da.SelectCommand.Parameters.Add("RCODE", OleDbType.Integer)
    da.SelectCommand.Parameters("RCODE").Direction =
    ParameterDirection.InputOutput
    da.SelectCommand.Parameters("RCODE").Value = 0

    Try

    cn.Open()
    da.SelectCommand.ExecuteNonQuery()
    MsgBox("RCODE = " &
    da.SelectCommand.Parameters("RCODE").Value.ToString)

    Catch e As Exception

    MsgBox(e.Source & " - " & e.Message)

    Finally

    cn.Close()

    End Try