spragueg Posted June 23, 2008 Posted June 23, 2008 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
Wim Decorte Posted June 26, 2008 Posted June 26, 2008 IIRC you will need to specify more options for the openrecordset. The way you have it coded here is read-only by nature. Do a search on MS Technet for the available options.
Recommended Posts
This topic is 6037 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 accountSign in
Already have an account? Sign in here.
Sign In Now