|
-
Sep 5th, 2004, 05:08 PM
#1
Thread Starter
Addicted Member
Add record receives error message (resolved)
Hi,
Can anyone tell me why I kept getting this error message. I am trying to add a record into the database "test.mdb" and a table "table1".
ID | One | Two | Three | Four | Five | Six | Seven |
--------------------------------------------------
01 | 101 | 202 | 3003 | 404 | 505 | 66 | 71117 |
02 | 111 | 212 | 3113 | 414 | 515 | 66 | 72227 |
Thanks,
Phillip
"Run-time error '3251':"
"Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."
Code:
Private Sub Command6_Click()
Dim con As Adodb.Connection
Dim rs As Adodb.Recordset
Set con = New Adodb.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & InputFileName & ";"
con.Open
Set rs = con.Execute("SELECT One, Two, Three, Four, Five, Six, Seven FROM Table1")
With rs
.AddNew
.Fields("One") = Text1(13).Text
.Fields("Two") = Text1(12).Text
.Fields("Three") = Text1(11).Text
.Fields("Four") = Text1(10).Text
.Fields("Five") = Text1(9).Text
.Fields("Six") = Text1(8).Text
.Fields("Seven") = Text1(7).Text
.Update
.Close
End With
End Sub
Last edited by Iat; Sep 6th, 2004 at 08:53 AM.
-
Sep 5th, 2004, 10:05 PM
#2
Its because your not specifing the cursor and lock type, so it
uses the default, which are adOpenFowardOnly and
adLockReadOnly. Try changing your open statement to this.
VB Code:
Set rs = New ADODB.Recordset
rs.Open "SELECT One, Two, Three, Four, Five, Six, Seven FROM Table1", con, adOpenKeyset, adLockOptimistic, adCmdText
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2004, 08:54 AM
#3
Thread Starter
Addicted Member
Thanks Robdog88. That fixed my problem.
-
Sep 6th, 2004, 11:25 PM
#4
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|