Jump to content
Server Maintenance This Week. ×

VB rs.addNew - read only?


This topic is 5788 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm testing out using VB to add records to a FileMaker database served from FMS via ODBC.

As part of this test I first decided to see if I could just query the records in a certain table and get back some results which works fine here's my code.....

Dim ws As Workspace

Dim db As database

Dim strConnection As String

Dim rs As Recordset

Set ws = DBEngine.Workspaces(0)

Let strConnection = "ODBC;DSN=TSHC" & DatabaseName & ";UID=Admin" & UserName & ";PWD=" & UserPassword

Set db = ws.OpenDatabase("", False, False, strConnection)

Set rs = db.openrecordset("ENGLISH_NATURE")

Do While Not rs.EOF

'Put the code here for what to do with the information.

'The field information can be access by the field name

intID = rs!ID

intTitle = rs!Title

'Or by the order number it is in the list (starting at 0)

MsgBox intID & " - " & intTitle

rs.MoveNext

Loop

The next part of the test was to see if I could create a record. Here's my code which results in the following error at the rs.addNew line: "Database or Object is read only". The database is not read only. I am using the Admin user to connect which has full access to the file and also has ODBC access privs.

Dim ws As Workspace

Dim db As database

Dim strConnection As String

Dim rs As Recordset

Set ws = DBEngine.Workspaces(0)

Let strConnection = "ODBC;DSN=TSHC2" & DatabaseName & ";UID=Admin" & UserName & ";PWD=" & UserPassword

Set db = ws.OpenDatabase("", False, False, strConnection)

'DAO - Add New Record

Set rs = db.openrecordset("ENGLISH_NATURE")

' ERROR OCCURS ON THE NEXT LINE...

rs.AddNew

rs!ID = intID

rs!Name = "Test"

rs!Status = "Popular"

rs!Author = "Graham Sprague"

rs!Publisher = "Somepublisher, Inc."

rs.Update

Link to comment
Share on other sites

This topic is 5788 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.