WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE COM ADO CDO ADSI LDAP
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Write/Read DBF

Keywords: 	 Write/Read DBF  Jet 4.0 ISAMS

Question:

Whats wrong?
Errormessage:
1261 OLE:Exception
DB.Execute(cSQL)
Code:
;==========
cMDB = "C:\TEST\Inventar.dbf"
cMDBPath = FilePath(cMDB)

cConn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cMDBPath%; Extended Properties=dBASE IV;"
DB = ObjectOpen("ADODB.Connection")
DB.Open(cConn)

cSQL = "INSERT INTO %cMDB% ( 'USER' ) VALUES ('TEST')"
DB.Execute(cSQL)

DB.close()
ObjectClose(DB)
Have anyone a sample who works? I want to read and write into an DBASE file. The table has a Field USER!

Answer:

Try inserting into just the filename ( no path/no DBF extension.

Jet 4.0 uses the path as the database and the filename as the table with ISAMS.

Also, you have to specify a cursor and locktype in order to insert into an existing table, since by default it will be opened as readonly.

Below is an example I posted for another user a long time ago :

BoxOpen("Test Script","Creating/Inserting dBase IV")
cPath = "E:\WBDEMO\
If FileExist("%cpath%DBF.DBF")
   FileDelete("%cpath%DBF.DBF")
Endif
cConn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cPath%;Extended Properties=dBASE IV"
DB  = ObjectOpen("ADODB.Connection")
DB.Open(cConn)
step=1
cSQL = "CREATE TABLE DB4 ( COLUMN_1 TEXT(50) );"
DB.Execute(cSQL)
;this works
;cSQL = "INSERT INTO DB4 ( COLUMN_1 ) VALUES ('Joes Bar and Grill');"

;or this to include apostrophe in field
var="Joe''s Bar and Grill"
cSQL = "INSERT INTO DB4 ( COLUMN_1 ) VALUES ('%var%');"
DB.Execute(cSQL)

DB.close()
ObjectClose(DB)
BoxShut()
exit

Article ID:   W15235
File Created: 2002:09:05:13:50:46
Last Updated: 2002:09:05:13:50:46