Thread: sql hangs
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Richard Douglass Richard Douglass is offline
external usenet poster
 
Posts: 6
Default sql hangs

Nope that didnt work. Here is my routine

Private Sub btnLoadSheet_Click()
Application.ScreenUpdating = True

Call SetHeadings
If FormValid() = False Then GoTo LSExit

strDWFilePath = "Driver={SQL
Server};Server=TREMOLITE;Database=RDConv14_db_0827 2008;User Id=aris;"
Set cnnDW = New ADODB.Connection
Set rsDW = New ADODB.Recordset

Sheet1.Range("A2:P99").ClearContents

cnnDW.Open strDWFilePath

sQRY = "SELECT * " & _
"FROM adet x " & _
"WHERE x.license = '" & txtLicense.Text & "' " & _
IIf(txtSuffix.Text = "", "", "AND x.sf like '[" & txtSuffix.Text
& "]' ") & _
"AND x.wkpd between " & txtFromPd.Text & " and " & txtToPd.Text &
" " & _
"ORDER BY 1,2,3,x.wkpd"

rsDW.CursorLocation = adUseClient
rsDW.Open sQRY, cnnDW, adOpenDynamic, adLockOptimistic, adCmdText
Application.ScreenUpdating = False
Sheet1.Range("A2").CopyFromRecordset rsDW

rsDW.Close
Set rsDW = Nothing

cnnDW.Close
Set cnnDW = Nothing

Sheet1.Range("A2").Show
LSExit:

End Sub