LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using DSN-Less Connectino from Excel to SQL

Hi All,

Have trawled the posts and I guess I'm missing something. This is the
code I'm running...

Dim cnn As ADODB.Connection
Dim strConn As String
Set cnn = New ADODB.Connection
strConn = "Driver={SQL
Server};Server=POServer;Database=Live_Integra;Uid= xxx;Pwd=xxxxx;"
With cnn
.Open strConn
.CursorLocation = adUseClient
End With

'Get the total Quantity sold in that period
strSQL = "SELECT sum(c.QTY)"
strSQL = strSQL & " FROM acocmp1.currsale c WHERE (c.STKCODE Not In
('i98','SUBS'))"
strSQL = strSQL & " and c.trandate between '" & VarStartDate & "' and
'" & varEndDate & "'"
strSQL = strSQL & " and c.stkcode = '" & StockCode.Value & "'"


TotalQuantity = cnn.Execute(strSQL)
MsgBox ("Total Quantity = " & TotalQuantity)

This gives run time error 450 - wrong number of arguments or invalid
property assignment against the msgbox(totalquantity) line

This sits within the click event of a button. I've used message boxes
to make sure that the variables in the query are populated and that
the query returns a result if you run it in query analyser.

To be honest this is my first attempt at VBA - although I use vbscript
quite a bit to automate admin tasks...

I'm guessing that I've misunderstand how to run the query or how to
manipulate the response...

If anyone can help that would be incredible...

Paul

 
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



All times are GMT +1. The time now is 07:23 PM.

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"