Best way to add info to a SQL database from Excel

C

Chris

I am programming excel to update data from a spreadsheet
into a blank database. I can update the database if there
is a record in it but I can't seem to add a new record
(using .AddNew). I keep getting read only errors and I
cannot figure you what is wrong.

I am using DAO with a DSN to connect to a SQL server

Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
[MyUser], [MyPassword], dbUseODBC)
With dbsFITSDB
Set rstTemp = dbsFITSDB.OpenRecordset("my_input")

Set dbsFITSDB = wrkODBC.OpenConnection([Connect],
dbDriverNoPrompt, False)

strQueryUpdateFX = "UPDATE my_input ....... "
rstTemp.addnew
dbsFITSDB.Execute strQueryUpdateFX
End With
End With
Wend
dbsFITSDB.Close
wrkODBC.Close
End Sub

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top