View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chris Chris is offline
external usenet poster
 
Posts: 1
Default Best way to add info to a SQL database from Excel

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!