View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dchow dchow is offline
external usenet poster
 
Posts: 18
Default An ODBC question

I have been using the following to query a database through ODBC:

With ActiveSheet.QueryTables.Add(Connection:="ODBC;DATA BASE=DB;
UID=user;PWD=password;DSN=sDSN, Destination:=Range("A1"), Sql:=sSQL)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.PreserveColumnInfo = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

If sSQL is a SELECT, there is no problem. If it is a DELETE, I have to
set 'Refresh BackgroundQuery' to True. Otherwise I will get an
Application Defined or Object Defined error. What was wrong?