Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating dbase from VB, anyone?

Status
Not open for further replies.

DeltaTech

Programmer
Apr 16, 2003
92
MY
Hi
I am accessing a dbase file through VB to read and update data. While I can read, trying to perform an update causes the following error:

"-2147217911 (80040e09) Cannot update. Database or object is read only"

Here is my code:

[highlight]adoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & m_sPath & ";Extended Properties=dBASE IV;User ID=Admin;Password="

adoRS.Open "Select * From \" & m_sFileName, adoConn, adOpenDynamic, adLockOptimistic ', adCmdText
[/highlight]

What am I doing wrong?
Oh, and can passwords be set for dbf files through VB code?

Very much appreciated.
Thanks
[bigcheeks]
 
Is the DB on a CD or has it been copied from one? Sounds like you only have read access to the database file.

Do a right click, properties on the file in Windows Explorer and see if flagged as read-only.
 
Hi Glasgow
Nope the db is not on a CD neither is it readonly.
It's on a local drive.
Any other feedback, please?
[bigcheeks]

 
Can you open the database from another application/tool and update it there?

Does the open work as readonly - e.g.

adoRS.Open "Select * From \" & m_sFileName, adoConn, adOpenStatic, adLockReadOnly, adCmdText


 
Hi Glasgow
Apparently, Microsoft's newer data access components does not support updating dbase tables, and we should instead use DAO for this.
I tried and it works!
Check out Phew!
[bigcheeks]
 
Unusual decision on their part - FoxPro uses dbase IV tables...

mmilan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top