Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Recordset Update with *.DBF - HOW?

 
   Database Help (Home) -> Visual Basic RSS
Next:  Which control, and how to work with the multiple ..  
Author Message
Kaczala

External


Since: May 20, 2004
Posts: 10



(Msg. 1) Posted: Fri Jun 04, 2004 6:52 pm
Post subject: Recordset Update with *.DBF - HOW?
Archived from groups: microsoft>public>vb>database (more info?)

I have strange problem.
I have opened a DBF database and i cant update it.
When i perform simple operation

rs![NR] = "2222"
rs.Update

i doesnt work and i get error to ensure that database exists??!!
(the same DB that i've just opened)
(the same mistake occurs when i want to perform other
simple operation movenext etc.)

Is there another way to update a DATABASE when it is a dBASE file?
What am I doing wrong?


This is how I am opening the file:

Private Sub OpenDB(sFile)

Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

conn.mode = adModeShareDenyNone
conn.CursorLocation = adUseClient
conn.Open ("Driver={Microsoft dBASE Driver (*.dbf)};" & _
"SourceDB=" & sFile & ";" & _
"SourceType=DBF;Exclusive=No;BackgroundFetch=No;Collate=Machine;")

Dim strSQL As String: strSQL = "SELECT * FROM " & sFile

Set cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.Open cmd

Set MSHFlexGrid.DataSource = rs

End Sub
Private Sub OpenDB(sFile)

Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

conn.mode = adModeShareDenyNone
conn.CursorLocation = adUseClient
conn.Open ("Driver={Microsoft dBASE Driver (*.dbf)};" & _
"SourceDB=" & sFile & ";" & _
"SourceType=DBF;Exclusive=No;BackgroundFetch=No;Collate=Machine;")

Dim strSQL As String: strSQL = "SELECT * FROM " & sFile

Set cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.Open cmd

Set MSHFlexGrid.DataSource = rs

End Sub


PLEASE HELP ME
BEST WISHES

 >> Stay informed about: Recordset Update with *.DBF - HOW? 
Back to top
Login to vote
Stratocaster

External


Since: Jun 24, 2004
Posts: 1



(Msg. 2) Posted: Thu Jun 24, 2004 6:14 am
Post subject: Re: Recordset Update with *.DBF - HOW? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Based on personal experience I suggest that you leave ADO and use DAO
to work with dBASE tables. ADO has several known issues whereas DAO
3.51 works fine. This is a short example of how you can update a dBASE
table.

Dim wsp As DAO.Workspace
Dim jdb As DAO.Database
Set wsp = CreateWorkspace("JetWorkspace", "admin", "", dbUseJet)
Set jdb = wsp.OpenDatabase("D:\dBaseDir", False, False, "dBASE IV;")
jdb.Execute "UPDATE Table1 SET NR = '2222' WHERE Id=1"

Regards, Janne Hentschel

 >> Stay informed about: Recordset Update with *.DBF - HOW? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How to do a SELECT on a RecordSet - How would I do a SELECT on a ADODB.RecordSet? I have created the recordset from an Oracle database using a Select statement with a Group By. Now I need to Select from that result and further Group By and Sum. The logic of the statements don't allow for....

Move to specific row in an ADODB.recordset - Hello! I would like to move to a specific row in a recordset. For example I would like to get the value "MyText" from the 100. row. A very slow approach would be dim l& for l = 1 to rs.recordcount if l = 100 then ... Is there a faster...

update query - I have created an update query in my dataenvironment to change the date in the bound table to the sys date. However, the query will not accept '=Date' in the new value box. Does anyone know the correct function. The help gives it as 'Date' Ian

Can I Update entire record in SQL ? - Heya, I am working on making a SQL database an exact mirror of a local Access database. I check the .mdb database every few minutes for new entries, if there are new entries, I retrieve them and write them to an exact replica table in SQL. This all work...

NEWBIE insert data rather than update in db - I have an app for tracking mileage on company vehicles. On the first form you select a vehicle(via combobox getting vehicle names from database) and enter the appropriate info. Then I need to export that data back to the database. The ? is how do I....
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]