By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,723 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,723 IT Pros & Developers. It's quick & easy.

update dbase file with function

P: n/a
JFB
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

Jan 18 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JFB
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" <jf*@help.comwrote in message
news:eB****************@TK2MSFTNGP04.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

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



Jan 18 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.