An ODBC question

D

dchow

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

With ActiveSheet.QueryTables.Add(Connection:="ODBC;DATABASE=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?
 

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