Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Setting Connection Property to pass 3 parameters to an SQL Proc.

I am trying to connect to a SQL Stored Proc and pass 3 parameters. I can
sucessfully pass both date parameters, but the string parameter, @SalesRep in
the procedure gives an error message. "Compile Error, Snytax Error". Below
is the connection string I am attempting to use:

With CMD
.ActiveConnection = CN
.CommandText = "SALES_REP_INFORMATION"
.CommandType = adCmdStoredProc
.Parameters.Append.CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)
.Parameters.Append .CreateParameter("@BeginDate", adDate, adParamInput,
, datBeginDate) 'needs to be date
.Parameters.Append .CreateParameter("@EndDate", adDate, adParamInput, ,
datEndDate) 'needs to be date

End With

If I comment out the @Sales Rep the the information passes the date range to
the stored procedure correctly. I am collecting the parameters from specific
ranges on the Excel Sheet. The parameter for @SalesRep is a char(19) within
the stored proc but I am gathering the information as a string in VB.

Help I have check spelling, etc. and am having no luck. Anyone got any
suggestions for other areas to check.

Thanks

Normad

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Setting Connection Property to pass 3 parameters to an SQL Proc.

"NormaD" wrote:

I am trying to connect to a SQL Stored Proc and pass 3 parameters. I can
sucessfully pass both date parameters, but the string parameter, @SalesRep in
the procedure gives an error message. "Compile Error, Snytax Error". Below
is the connection string I am attempting to use:

With CMD
.ActiveConnection = CN
.CommandText = "SALES_REP_INFORMATION"
.CommandType = adCmdStoredProc
.Parameters.Append.CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)
.Parameters.Append .CreateParameter("@BeginDate", adDate, adParamInput,
, datBeginDate) 'needs to be date
.Parameters.Append .CreateParameter("@EndDate", adDate, adParamInput, ,
datEndDate) 'needs to be date

End With

If I comment out the @Sales Rep the the information passes the date range to
the stored procedure correctly. I am collecting the parameters from specific
ranges on the Excel Sheet. The parameter for @SalesRep is a char(19) within
the stored proc but I am gathering the information as a string in VB.

Help I have check spelling, etc. and am having no luck. Anyone got any
suggestions for other areas to check.

Thanks

Normad


On this line:

.Parameters.Append.CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)

you need a space between Append and .CreateParameter:

.Parameters.Append .CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)


Hope this helps.

--
urkec
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Setting Connection Property to pass 3 parameters to an SQL Pro

Thank you for your help. That was one of my problems the other was setting
the correct type of variable to pass information into my Stored Procedure.
It took a lot of just plain trial and error, the Excel side would use let me
declare a variant type and the stored procedure allowed me to use a
sql_variant after that everything ran smoothly.

"urkec" wrote:

"NormaD" wrote:

I am trying to connect to a SQL Stored Proc and pass 3 parameters. I can
sucessfully pass both date parameters, but the string parameter, @SalesRep in
the procedure gives an error message. "Compile Error, Snytax Error". Below
is the connection string I am attempting to use:

With CMD
.ActiveConnection = CN
.CommandText = "SALES_REP_INFORMATION"
.CommandType = adCmdStoredProc
.Parameters.Append.CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)
.Parameters.Append .CreateParameter("@BeginDate", adDate, adParamInput,
, datBeginDate) 'needs to be date
.Parameters.Append .CreateParameter("@EndDate", adDate, adParamInput, ,
datEndDate) 'needs to be date

End With

If I comment out the @Sales Rep the the information passes the date range to
the stored procedure correctly. I am collecting the parameters from specific
ranges on the Excel Sheet. The parameter for @SalesRep is a char(19) within
the stored proc but I am gathering the information as a string in VB.

Help I have check spelling, etc. and am having no luck. Anyone got any
suggestions for other areas to check.

Thanks

Normad


On this line:

.Parameters.Append.CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)

you need a space between Append and .CreateParameter:

.Parameters.Append .CreateParameter("@SalesRep", adChar, adParamInput,
strSalesRep)


Hope this helps.

--
urkec

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
how to pass on different parameters to VBA Code? Ahmaq Excel Worksheet Functions 2 April 22nd 07 04:30 AM
How to pass address(es) as parameters Pat Excel Programming 12 May 22nd 06 03:15 AM
SQL Stored proc - passing parameters Harish Mohanbabu[_3_] Excel Programming 1 April 20th 06 05:55 PM
How do I pass parameters into Excel from a URL? David Jankowski Excel Programming 0 April 4th 06 09:52 PM
Calling stored proc with parameters .. Harish Mohanbab[_3_] Excel Programming 2 September 19th 05 03:58 PM


All times are GMT +1. The time now is 12:14 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"