#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default sql hangs

I am writing some code that runs in a form to get records from a sql
database. The recordset comes back clean and has the records I expected and
the sheet gets the command to populate but then nothing happens.

When I kill the VBA form the sheet refreshes with the data. before I kill
it the form is in hung mode. when I drag it around it leaves a trail.

any ideas?


  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default sql hangs

Look at the ninth row up from bottom...

"Application.ScreenUpdating = False
Sheet1.Range("A2").CopyFromRecordset rsDW"
--
Jim Cone
Portland, Oregon USA



"Richard Douglass"

wrote in message
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default sql hangs

Jim thank you very much.


That did it.


"Jim Cone" wrote in message
...
Look at the ninth row up from bottom...

"Application.ScreenUpdating = False
Sheet1.Range("A2").CopyFromRecordset rsDW"
--
Jim Cone
Portland, Oregon USA



"Richard Douglass"

wrote in message
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sql hangs Jim Cone[_2_] Excel Programming 0 June 15th 09 04:48 AM
Excel hangs up. bc Excel Discussion (Misc queries) 0 February 28th 06 06:30 PM
Excel hangs Oxns Excel Programming 9 February 24th 06 05:32 AM
VBA Hangs sponny Excel Programming 2 November 4th 05 02:58 PM
DDE Startup Hangs amac Excel Programming 1 November 10th 04 02:58 PM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"