Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to make DAO recodset updatable to add a new record to SQL Server 2008 table. Expand / Collapse
Author
Message
Posted Monday, January 14, 2013 10:17 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 15, 2013 1:01 AM
Points: 1, Visits: 4
Hi,

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. I could make out that my recordset is not updatable.

http://msdn.microsoft.com/en-us/library/office/bb243801(v=office.12).aspx

Is there a way to make it udatable? Is there a way to overcome this problem?

Below is my code sample. Database=Sales, User=user, Table name= DocTab1
--------------------
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
'---------------
Error_Handler:
If (ErrorLineNum = 0) Then
ErrorLineNum = Erl
End If

MsgBox (ErrorLineNum & Err.Description)
End Sub



-------------------------
Thanks for any help,
Swapna
Post #1407025
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse