Can't using vb.net to retrieve data from .mdb - InfoPath Dev
in

InfoPath Dev

Can't using vb.net to retrieve data from .mdb

Last post 07-14-2006 02:41 PM by garym. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-12-2006 02:13 AM

    Can't using vb.net to retrieve data from .mdb

    hi,

    I want to retrive the data from access database, but got error message pop out As shown below.

    System.Data.OleDb.OleDbException
    No value given for one or more required parameters.
    at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
    at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
    at System.Data.OleDb.OleDbCommand.ExecuteReader()
    at eLeave.eLeave.CTRL_Submit_OnClick(DocActionEvent e)
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)



    Hope someone can help. this is my coding as shown as below.


    ' The following function handler is created by Microsoft Office InfoPath. Do not
    ' modify the type or number of arguments.
    <InfoPathEventHandler(MatchPath:="CTRL_Submit", EventType:=InfoPathEventType.OnClick)> _

    Public Sub CTRL_Submit_OnClick(ByVal e As DocActionEvent)
    ' Write your code here.

    Dim strconnection As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\eLeave.mdb"
    Dim cn As OleDbConnection = New OleDbConnection(strconnection)


    Dim strselect As String = "SELECT LeaveBalance " & _
    "FROM StaffDetail " & _
    "WHERE StaffNo = 3000"

    Dim ocmd As New OleDbCommand(strselect, cn)

    cn.Open()

    Dim dr As OleDbDataReader = ocmd.ExecuteReader()
    thisXDocument.DOM.selectSingleNode("//my:LeaveAvailable").text = strselect

    cn.Close()

    End Sub



    Please kindly to advise.
    thanks.
  • 07-14-2006 02:41 PM In reply to

    • garym
    • Top 500 Contributor
    • Joined on 07-12-2006
    • USA
    • Posts 29

    Re: Can't using vb.net to retrieve data from .mdb

    I belive you need to modify the following code

    Dim dr As OleDbDataReader = ocmd.ExecuteReader()
    thisXDocument.DOM.selectSingleNode("//my:LeaveAvailable").text = strselect

    to something like this

    Dim dr As OleDbDataReader = ocmd.ExecuteReader()
    dr.reader()
    thisXDocument.DOM.selectSingleNode("//my:LeaveAvailable").text = dr.GetString(0)

    Hope this helps
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.