Connecting Tech Pros Worldwide Forums | Help | Site Map

update dbase file with function

JFB
Guest
 
Posts: n/a
#1: Jan 18 '08
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

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
filePath & ";Extended Properties=dBase IV"

Dim dBaseConnection As New
System.Data.OleDb.OleDbConnection(ConnectionString )

Try

dBaseConnection.Open()

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

dBaseCommand.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.ToString)

Finally

dBaseConnection.Close()

End Try

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

bla...bla....

End Function








JFB
Guest
 
Posts: n/a
#2: Jan 18 '08

re: update dbase file with function


Got it... FYI

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
filePath & ";Extended Properties=dBase IV"

Dim dBaseConnection As New
System.Data.OleDb.OleDbConnection(ConnectionString )

Try

dBaseConnection.Open()

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

Dim dBaseDataReader As System.Data.OleDb.OleDbDataReader =
dBaseCommand.ExecuteReader(CommandBehavior.Sequent ialAccess)

While dBaseDataReader.Read

Dim parameter1 As String = dBaseDataReader("Colum2").ToString

Dim parameter2 As String = dBaseDataReader("Colum3").ToString

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

updateCommand.ExecuteNonQuery()

End While

Catch ex As Exception

MsgBox(ex.ToString)

Finally

dBaseConnection.Close()

End Try

"JFB" <jfb@help.comwrote in message
news:eB3%23HdeWIHA.1188@TK2MSFTNGP04.phx.gbl...
Quote:
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
>
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
filePath & ";Extended Properties=dBase IV"
>
Dim dBaseConnection As New
System.Data.OleDb.OleDbConnection(ConnectionString )
>
Try
>
dBaseConnection.Open()
>
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand("update " & dbfFile
&
" set Column4 = FSB(Column1, Column2)", dBaseConnection)
>
dBaseCommand.ExecuteNonQuery()
>
Catch ex As Exception
>
MsgBox(ex.ToString)
>
Finally
>
dBaseConnection.Close()
>
End Try
>
Function FSB(ByVal inTrack As String, ByVal inRoute As String) As String
>
bla...bla....
>
End Function
>
>
>
>
>

Closed Thread