Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB / SQL help with add records

Status
Not open for further replies.

cORDOBEx

Technical User
May 21, 2001
7
0
0
US
First at all: I'm not a vb programmer, so please be patient with me. I just started and I'm working in a small project in which I need to move certain information from an Access database to a SQL 6.5 database.
I could open both databases pretty well, but I'm getting an error that says:
Run-time error '3027'
Cant't update. Database or object is read-only.
The line where I'm getting this error is marked with a (*).
As I said, I'm new to vb and I know I'm doing something wrong here, but I can't figure out what it is.
I'l be VERY grateful for any help.

Here is the code:

Sub First()
Set dbSQL65 = OpenDatabase("Harris", dbDriverNoPrompt, False, "ODBC;DATABASE=TestHarris;UID=sa;PWD=;DSN=Harris")
Set rsSQL65 = dbSQL65.OpenRecordset("Test", dbOpenDynaset)
Set dbHarris = OpenDatabase("File.mdb", False, False)
Set rsHarris = dbHarris.OpenTable("Table1")

Call Export

End Sub

Private Sub Export()
rsHarris.MoveFirst
Do
rsSQL65.AddNew (*)
rsSQL65("FIELD1") = rsHarris("NAME_1ST")
rsSQL65("FIELD2") = rsHarris("NAME_LAST")
rsSQL65("FIELD3") = rsHarris("COUNTY")
rsSQL65.Update
rsHarris.MoveNext
Loop Until rsHarris.EOF
End Sub
 
Try moving the addnew outside of the Do section,
so that it is a stand-alone command. Jim

oracle, vb
 
Thanks, I just did that with the same result error messagge.
Any other suggestion?
 
OK, forget my first suggestion.
The error message seems to be indicating that "Test"
is read only. Can you verify that? Can you write a short
routine that opens up Test, reads it, and attempts to
update it? Use debug and highlight the various variables
to see their values, if necessary. Also, can you update
Test 'manually'? Jim

oracle, vb
 
Thanks. "Test" is not read-only, it's a SQL table and I was adding stuff and I didn't have problems doing this manually.
Right now I've replaced the code rsSQL65.AddNew with a SQL sentence, using rsSQL65.Excecute and looks that is working fine.
So far I could add new records and everything seems to work fine.
Thanks for your tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top