update dbase file with function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JFB

    #1

    update dbase file with function

    Hi,
    I have a connection to a dbase IV file using oledb. I wan to do an update to
    a field using a vb function passing two parameters. These 2 parameters are
    fields from the same table.
    What is the sintax to do this?
    Thanks

    JFB

    ConnectionStrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    filePath & ";Extended Properties=dBas e IV"

    Dim dBaseConnection As New
    System.Data.Ole Db.OleDbConnect ion(ConnectionS tring)

    Try

    dBaseConnection .Open()

    Dim dBaseCommand As New System.Data.Ole Db.OleDbCommand ("update " & dbfFile &
    " set Column4 = FSB(Column1, Column2)", dBaseConnection )

    dBaseCommand.Ex ecuteNonQuery()

    Catch ex As Exception

    MsgBox(ex.ToStr ing)

    Finally

    dBaseConnection .Close()

    End Try

    Function FSB(ByVal inTrack As String, ByVal inRoute As String) As String

    bla...bla....

    End Function





  • JFB

    #2
    Re: update dbase file with function

    Got it... FYI

    ConnectionStrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    filePath & ";Extended Properties=dBas e IV"

    Dim dBaseConnection As New
    System.Data.Ole Db.OleDbConnect ion(ConnectionS tring)

    Try

    dBaseConnection .Open()

    Dim dBaseCommand As New System.Data.Ole Db.OleDbCommand ("select * from " &
    dbfFile, dBaseConnection )

    Dim dBaseDataReader As System.Data.Ole Db.OleDbDataRea der =
    dBaseCommand.Ex ecuteReader(Com mandBehavior.Se quentialAccess)

    While dBaseDataReader .Read

    Dim parameter1 As String = dBaseDataReader ("Colum2").ToSt ring

    Dim parameter2 As String = dBaseDataReader ("Colum3").ToSt ring

    Dim updateCommand As New System.Data.Ole Db.OleDbCommand ("update " & dbfFile
    & " set Column4 = '" & FSB(parameter1, parameter2) & "' where Column2 = '" &
    parameter1 & "' and Column3 = '" & parameter2 & "'", dBaseConnection )

    updateCommand.E xecuteNonQuery( )

    End While

    Catch ex As Exception

    MsgBox(ex.ToStr ing)

    Finally

    dBaseConnection .Close()

    End Try

    "JFB" <jfb@help.comwr ote in message
    news:eB3%23HdeW IHA.1188@TK2MSF TNGP04.phx.gbl. ..
    Hi,
    I have a connection to a dbase IV file using oledb. I wan to do an update
    to
    a field using a vb function passing two parameters. These 2 parameters are
    fields from the same table.
    What is the sintax to do this?
    Thanks
    >
    JFB
    >
    ConnectionStrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    filePath & ";Extended Properties=dBas e IV"
    >
    Dim dBaseConnection As New
    System.Data.Ole Db.OleDbConnect ion(ConnectionS tring)
    >
    Try
    >
    dBaseConnection .Open()
    >
    Dim dBaseCommand As New System.Data.Ole Db.OleDbCommand ("update " & dbfFile
    &
    " set Column4 = FSB(Column1, Column2)", dBaseConnection )
    >
    dBaseCommand.Ex ecuteNonQuery()
    >
    Catch ex As Exception
    >
    MsgBox(ex.ToStr ing)
    >
    Finally
    >
    dBaseConnection .Close()
    >
    End Try
    >
    Function FSB(ByVal inTrack As String, ByVal inRoute As String) As String
    >
    bla...bla....
    >
    End Function
    >
    >
    >
    >
    >

    Comment

    Working...