Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Adding new record to a SQL server 2008 using DAO
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Arab Emirates
1 Posts

Posted - 01/14/2013 :  14:10:00  Show Profile  Reply with Quote

I am trying to add a recod to a SQL Server 2008 table using DAO.AddNew. But this is giving me Database readonly err at runtime. Is there a way to overcome this problem?

Below is my code sample.
Option Explicit
Dim grsIndexTable As Recordset
Dim grsDocTable As Recordset
Public DBConnection As Database
Public oWorkSpace As Workspace
Public oDbEngine As New PrivDBEngine
Public ErrorLineNum As Integer

Private Sub Form_Load()
On Error GoTo Error_Handler
530 Set oWorkSpace = oDbEngine.CreateWorkspace("Test", "Admin", "")
540 Set DBConnection = oWorkSpace.OpenDatabase("", False, False, "ODBC;DSN=Sales;UID=user;PWD=")
1020 Set grsDocTable = DBConnection.OpenRecordset("DocTab1")
MsgBox (grsDocTable.Updatable)
1234 grsDocTable.AddNew
1120 grsDocTable.Fields("DocID") = 3
1130 grsDocTable.Fields("Path") = "My Path"
1140 grsDocTable.Update
Exit Sub
' Error Handler
If (ErrorLineNum = 0) Then
ErrorLineNum = Erl
End If

MsgBox (ErrorLineNum & Err.Description)
End Sub

Thanks for any help,

Starting Member

47 Posts

Posted - 01/15/2013 :  09:09:01  Show Profile  Reply with Quote
If you need help with an error it would help if you posted the error.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000