943,981 Members | Top Members by Rank

Ad:
Jan 26th, 2005
0

Addnew problem

Expand Post »
Im wondering if anyone can suggest a solution to my problem. Im simply trying to connect to a database through VB 6 and add a new record and populate one of the fields.
Any help would be great.


The code below throws up error message 'Current Recordset does not support updating. This may be a limitation of the provider or of the selected locktype'


Dim adoConnection As ADODB.Connection
Dim adoRecordset As ADODB.Recordset
Dim connectString As String
Dim RecordSQL As String

RecordSQL = "SELECT * From Programme"

Set adoConnection = New ADODB.Connection
Set adoRecordset = New ADODB.Recordset

connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\MyDatabase.mdb"
adoConnection.Open connectString
adoRecordset.Open RecordSQL, adoConnection

adoRecordset.AddNew
adoRecordset!UserName = txtProgrammeNumber.Text
adoRecordset.Update

adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jksmithyuk is offline Offline
1 posts
since Jan 2005
Jan 26th, 2005
0

Re: Addnew problem

Please take a look at my ADO Tutorial. This will tell you the correct code to us. I'd say the problem is in your connection string, you may need to add a ';Mode=Read|Write;Persist ' segment to the string.
Reputation Points: 16
Solved Threads: 1
Posting Whiz in Training
mnemtsas is offline Offline
200 posts
since Jul 2004
Jan 27th, 2005
0

Re: Addnew problem

hi there,
i have just being doing then ADO objects in college over the past week and from what i have gathered, you seem to be going quite a long way around this. if you use less codes for this and instead just change properties in the properties window in VB while the ADO object is selected, it can be done easier. just try changing the properties of the connection string and record source.
then code a command button i.e. cmdNew with the Recordset.AddNew command. i will be back at college tomorrow and i will be able to post the full code if this helps
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lostprophet is offline Offline
5 posts
since Jan 2005
Feb 25th, 2005
0

Re: Addnew problem

Hi, it looks as though in the connection properties that you have selected a read-only connection, hence not being able to update.
try changing that.
Reputation Points: 49
Solved Threads: 11
Posting Whiz in Training
uniquestar is offline Offline
239 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: link record in database with contactItem?
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 and MS Access 2002





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC