dbTalk Databases Forums  

Error message calling stored procedure with parameter

comp.databases.ms-access comp.databases.ms-access


Discuss Error message calling stored procedure with parameter in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
hedgracer
 
Posts: n/a

Default Error message calling stored procedure with parameter - 04-07-2010 , 10:48 AM






I have the following VBA code:

Dim strMonth As String
strMonth = Me.cboOnyxAllocationHistoryMonth.Value
strCnxn = set_connection()
Set cnxn = New ADODB.Connection
cnxn.Open strCnxn
strSQL_Execute = "dbo.Onyx_Allocation_Report_Creation " &
strMonth
MsgBox strSQL_Execute
cnxn.Execute strSQL_Execute, , adExecuteNoRecords

The parameter being passed in strMonth is "02/28/2010". When I run the
stored procedure in SQL Server 2005 the procedure runs just fine. The
error message I get is as follows:

Incorrect syntax near '/'.

This error message is coming from the following line:

cnxn.Execute strSQL_Execute, , adExecuteNoRecords

I have never run into this before and have googled this to death. Any
help on this is greatly appreciated. Thanks.Dave

Reply With Quote
  #2  
Old   
Bruce
 
Posts: n/a

Default Re: Error message calling stored procedure with parameter - 04-07-2010 , 04:15 PM






On Apr 7, 10:48*am, hedgracer <d.christ... (AT) sbcglobal (DOT) net> wrote:
Quote:
I have the following VBA code:

Dim strMonth As String
strMonth = Me.cboOnyxAllocationHistoryMonth.Value
strCnxn = set_connection()
Set cnxn = New ADODB.Connection
cnxn.Open strCnxn
strSQL_Execute = "dbo.Onyx_Allocation_Report_Creation " &
strMonth
MsgBox strSQL_Execute
cnxn.Execute strSQL_Execute, , adExecuteNoRecords

The parameter being passed in strMonth is "02/28/2010". When I run the
stored procedure in SQL Server 2005 the procedure runs just fine. The
error message I get is as follows:

Incorrect syntax near '/'.

This error message is coming from the following line:

* * cnxn.Execute strSQL_Execute, , adExecuteNoRecords

I have never run into this before and have googled this to death. Any
help on this is greatly appreciated. Thanks.Dave
I think you need to include single quotes around your date parameter,
e.g.

strSQL_Execute = "dbo.Onyx_Allocation_Report_Creation '" & strMonth &
"'"

Bruce

Reply With Quote
  #3  
Old   
Rich P
 
Posts: n/a

Default Re: Error message calling stored procedure with parameter - 04-07-2010 , 05:52 PM



I would try it this way instead. This is a little more sure of a deal

Dim cmd As New ADODB.Command

'--this one uses Sql Server Authentication
'cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourSqlSvr;Database=yourSqlSvrDB;UID=steve; password=tiger;"


'--this connection uses Windows Authentication
cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourSqlSvr;Database=yourSqlSvrDB;Trusted_Co nnection=Yes"

cmd.commandText = "YourProc"
cmd.CommandType = adCmdStoredProc
cmd.parameters.Append .CreateParameter("@RecordID", adInteger,
adParamInput, , RecordID)
cmd.Parameters("@RecordID").Value = 12345
cmd.Execute , , adExecuteNoRecords


Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.