hI,
i'M TRTYING TO PASS PARAMETER TO A SP.BUT GETTING "OUT OF RANGE ERROR ERROR
FOLLOWING IS THE CODE:
Dim conDG As SqlClient.SqlCo nnection
Dim cmdDG As SqlClient.SqlCo mmand
Dim drDG As SqlClient.SqlDa taReader
Dim dtDueYear As String
Dim sqldataAdapter1 As SqlClient.SqlDa taAdapter
dtDueYear = Trim(txtYear.Te xt)
' If (IsDate(dtDueYe ar) = True) Then
conDG = New
SqlClient.SqlCo nnection("Serve r=SQLDB;UID=PWD ;pwd=;Database= SampleDB")
cmdDG = New SqlClient.SqlCo mmand("USE testdb EXEC
sp_CrossTabTask
'Task_T','Initi al_CH','Initial s','Convert(cha r(3),Due_Date_D T)','DATEPART(Y YYY,Due_Date_DT )'", conDG).Paramete rs(@dDate).Valu e ' = trim(dtDueYear. text)
where dDate is the parameter I have declared int the Stored procedure.
Thanks in advance.. 6 3716
1. Specify the database that you want to operate against in the connection
string, rather than in the command.
2. In the command, specify only the stored proc name.
3. Set the command to be of CommandType = StoredProc.
4. Set each parameter for the command.
5. Execute the command.
Your current command string is executing the stored proc directly, and
passes the parameters to it.
Apart from that, your parameter @dDate is not in the parameters collection,
thus the out of range error.
"gurvar" <gu****@discuss ions.microsoft. com> wrote in message
news:5D******** *************** ***********@mic rosoft.com... hI, i'M TRTYING TO PASS PARAMETER TO A SP.BUT GETTING "OUT OF RANGE ERROR ERROR FOLLOWING IS THE CODE: Dim conDG As SqlClient.SqlCo nnection Dim cmdDG As SqlClient.SqlCo mmand Dim drDG As SqlClient.SqlDa taReader Dim dtDueYear As String Dim sqldataAdapter1 As SqlClient.SqlDa taAdapter dtDueYear = Trim(txtYear.Te xt) ' If (IsDate(dtDueYe ar) = True) Then conDG = New SqlClient.SqlCo nnection("Serve r=SQLDB;UID=PWD ;pwd=;Database= SampleDB") cmdDG = New SqlClient.SqlCo mmand("USE testdb EXEC sp_CrossTabTask 'Task_T','Initi al_CH','Initial s','Convert(cha r(3),Due_Date_D T)','DATEPART(Y YYY,Due_Date_DT )'", conDG).Paramete rs(@dDate).Valu e ' = trim(dtDueYear. text)
where dDate is the parameter I have declared int the Stored procedure.
Thanks in advance..
Gurvar,
Have a look at this sample on our website. That you use a Stored Procedure
is completely inrelevant for programming with AdoNet. It only tells that you
have the command on the server. http://www.vb-tips.com/default.aspx?...6-7139b8970071
I hope this helps,
Cor
Thanks for a very informative link. I was able to do the con/cmd.
but I'm stuck at the Add parameter part.
Following is the error I'm getting:
The SqlParameterCol lection only accepts non-null SqlParameter type objects,
not String objects.
-------------------------
cmdDG = New
SqlClient.SqlCo mmand("sp_Cross TabTask('Task_T ','month(Due_Da te_DT)','MonthI nitials','Initi al_CH','CONVERT (char(3),Due_Da te_DT)'
cmdDG.CommandTy pe = CommandType.Sto redProcedure
cmdDG.Parameter s.Add("@table", sysname) ' There is no sysname for dbType
cmdDG.Parameter s.Add("@onrows" , "month(Due_Date _DT)") '
cmdDG.Parameter s.Add("@onrowsa lias", "MonthsInitials ")
cmdDG.Parameter s.Add("@oncols" , Trim(txtYear.Te xt).tostring)
sp_CrossTabTask
'Task_T','month (Due_Date_DT)', 'MonthsInitials ','Convert(char 93),Due_Date)DT =
'2003') --works on SQL server
@table AS sysname, --Table to crosstab
@onrows AS nvarchar(128), --Grouping key values(on rows)
@onrowsalias AS sysname = NULL, --Alias for grouping column
@oncols AS nvarchar(128), --Destination columns (on columns)
@Date AS nvarchar(128),
@sumcol AS sysname = NULL --Data cells
Thanks,
Sangeetha
"Cor Ligthert [MVP]" wrote: Gurvar,
Have a look at this sample on our website. That you use a Stored Procedure is completely inrelevant for programming with AdoNet. It only tells that you have the command on the server.
http://www.vb-tips.com/default.aspx?...6-7139b8970071
I hope this helps,
Cor
Try something like this:
cmdDG = New SqlClient.SqlCo mmand("sp_Cross TabTask")
cmdDG.CommandTy pe = CommandType.Sto redProcedure
cmdDG.Parameter s.Add("@table", value_of_table)
cmdDG.Parameter s.Add("@onrows" , whatever_here)
cmdDG.Parameter s.Add("@onrowsa lias", whatever_here)
cmdDG.Parameter s.Add("@oncols" , whatever_here)
"gurvar" <gu****@discuss ions.microsoft. com> wrote in message
news:EC******** *************** ***********@mic rosoft.com... Thanks for a very informative link. I was able to do the con/cmd. but I'm stuck at the Add parameter part. Following is the error I'm getting:
The SqlParameterCol lection only accepts non-null SqlParameter type objects, not String objects. ------------------------- cmdDG = New SqlClient.SqlCo mmand("sp_Cross TabTask('Task_T ','month(Due_Da te_DT)','MonthI nitials','Initi al_CH','CONVERT (char(3),Due_Da te_DT)'
cmdDG.CommandTy pe = CommandType.Sto redProcedure cmdDG.Parameter s.Add("@table", sysname) ' There is no sysname for dbType cmdDG.Parameter s.Add("@onrows" , "month(Due_Date _DT)") ' cmdDG.Parameter s.Add("@onrowsa lias", "MonthsInitials ") cmdDG.Parameter s.Add("@oncols" , Trim(txtYear.Te xt).tostring)
sp_CrossTabTask 'Task_T','month (Due_Date_DT)', 'MonthsInitials ','Convert(char 93),Due_Date)DT = '2003') --works on SQL server
@table AS sysname, --Table to crosstab @onrows AS nvarchar(128), --Grouping key values(on rows) @onrowsalias AS sysname = NULL, --Alias for grouping column @oncols AS nvarchar(128), --Destination columns (on columns) @Date AS nvarchar(128), @sumcol AS sysname = NULL --Data cells
Thanks, Sangeetha "Cor Ligthert [MVP]" wrote:
Gurvar,
Have a look at this sample on our website. That you use a Stored Procedure is completely inrelevant for programming with AdoNet. It only tells that you have the command on the server.
http://www.vb-tips.com/default.aspx?...6-7139b8970071
I hope this helps,
Cor
Hi,
Thanks for all the help.I have come really close.
But having problem with sending the last input parameter which goes in the
WHERE clause as month(Due_Date_ DT) = @ddate
I'm getting error at "GROUP". Is it because the date charecter is declared
as @ddate nvarchar(128) but assigned to a Date funtion. But sent as a string
from UI?
cmdDG.Parameter s.Add("@ddate", trim(txtvalue.t ext))
Thanks in advance again...
"Brendan Green" wrote: Try something like this:
cmdDG = New SqlClient.SqlCo mmand("sp_Cross TabTask") cmdDG.CommandTy pe = CommandType.Sto redProcedure
cmdDG.Parameter s.Add("@table", value_of_table) cmdDG.Parameter s.Add("@onrows" , whatever_here) cmdDG.Parameter s.Add("@onrowsa lias", whatever_here) cmdDG.Parameter s.Add("@oncols" , whatever_here)
"gurvar" <gu****@discuss ions.microsoft. com> wrote in message news:EC******** *************** ***********@mic rosoft.com... Thanks for a very informative link. I was able to do the con/cmd. but I'm stuck at the Add parameter part. Following is the error I'm getting:
The SqlParameterCol lection only accepts non-null SqlParameter type objects, not String objects. ------------------------- cmdDG = New SqlClient.SqlCo mmand("sp_Cross TabTask('Task_T ','month(Due_Da te_DT)','MonthI nitials','Initi al_CH','CONVERT (char(3),Due_Da te_DT)'
cmdDG.CommandTy pe = CommandType.Sto redProcedure cmdDG.Parameter s.Add("@table", sysname) ' There is no sysname for dbType cmdDG.Parameter s.Add("@onrows" , "month(Due_Date _DT)") ' cmdDG.Parameter s.Add("@onrowsa lias", "MonthsInitials ") cmdDG.Parameter s.Add("@oncols" , Trim(txtYear.Te xt).tostring)
sp_CrossTabTask 'Task_T','month (Due_Date_DT)', 'MonthsInitials ','Convert(char 93),Due_Date)DT = '2003') --works on SQL server
@table AS sysname, --Table to crosstab @onrows AS nvarchar(128), --Grouping key values(on rows) @onrowsalias AS sysname = NULL, --Alias for grouping column @oncols AS nvarchar(128), --Destination columns (on columns) @Date AS nvarchar(128), @sumcol AS sysname = NULL --Data cells
Thanks, Sangeetha "Cor Ligthert [MVP]" wrote:
Gurvar,
Have a look at this sample on our website. That you use a Stored Procedure is completely inrelevant for programming with AdoNet. It only tells that you have the command on the server.
http://www.vb-tips.com/default.aspx?...6-7139b8970071
I hope this helps,
Cor
Can you post the exact error message, along with the code for the stored
proc?
"gurvar" <gu****@discuss ions.microsoft. com> wrote in message
news:7B******** *************** ***********@mic rosoft.com... Hi, Thanks for all the help.I have come really close. But having problem with sending the last input parameter which goes in the WHERE clause as month(Due_Date_ DT) = @ddate
I'm getting error at "GROUP". Is it because the date charecter is declared as @ddate nvarchar(128) but assigned to a Date funtion. But sent as a string from UI?
cmdDG.Parameter s.Add("@ddate", trim(txtvalue.t ext))
Thanks in advance again... "Brendan Green" wrote:
Try something like this:
cmdDG = New SqlClient.SqlCo mmand("sp_Cross TabTask") cmdDG.CommandTy pe = CommandType.Sto redProcedure
cmdDG.Parameter s.Add("@table", value_of_table) cmdDG.Parameter s.Add("@onrows" , whatever_here) cmdDG.Parameter s.Add("@onrowsa lias", whatever_here) cmdDG.Parameter s.Add("@oncols" , whatever_here)
"gurvar" <gu****@discuss ions.microsoft. com> wrote in message news:EC******** *************** ***********@mic rosoft.com... > Thanks for a very informative link. I was able to do the con/cmd. > but I'm stuck at the Add parameter part. > Following is the error I'm getting: > > The SqlParameterCol lection only accepts non-null SqlParameter type > objects, > not String objects. > ------------------------- > cmdDG = New > SqlClient.SqlCo mmand("sp_Cross TabTask('Task_T ','month(Due_Da te_DT)','MonthI nitials','Initi al_CH','CONVERT (char(3),Due_Da te_DT)' > > cmdDG.CommandTy pe = CommandType.Sto redProcedure > cmdDG.Parameter s.Add("@table", sysname) ' There is no sysname for > dbType > cmdDG.Parameter s.Add("@onrows" , "month(Due_Date _DT)") ' > cmdDG.Parameter s.Add("@onrowsa lias", "MonthsInitials ") > cmdDG.Parameter s.Add("@oncols" , Trim(txtYear.Te xt).tostring) > > > sp_CrossTabTask > 'Task_T','month (Due_Date_DT)', 'MonthsInitials ','Convert(char 93),Due_Date)DT > = > '2003') --works on SQL server > > @table AS sysname, --Table to crosstab > @onrows AS nvarchar(128), --Grouping key values(on rows) > @onrowsalias AS sysname = NULL, --Alias for grouping column > @oncols AS nvarchar(128), --Destination columns (on columns) > @Date AS nvarchar(128), > @sumcol AS sysname = NULL --Data cells > > Thanks, > Sangeetha > "Cor Ligthert [MVP]" wrote: > >> Gurvar, >> >> Have a look at this sample on our website. That you use a Stored >> Procedure >> is completely inrelevant for programming with AdoNet. It only tells >> that >> you >> have the command on the server. >> >> http://www.vb-tips.com/default.aspx?...6-7139b8970071 >> >> I hope this helps, >> >> Cor >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: WGW |
last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost!
everything I need. Maybe not efficiently, but usefully. However, I have
a problem -- a complex query problem...
I can create a parameter query in a stored procedure, but how do I use
the result set of a parameter query in a select query (in the same or
another sp)? In short, if a select query contains a result table that is
generated as a parameter query, how do I...
|
by: Ranginald |
last post by:
Hi,
I'm having trouble passing a parameter from my default.aspx page to my
default2.aspx page.
I have values from a query in a list box and the goal is to pass the
"catID" from default.aspx to a stored procedure on the details2.aspx
page.
I can successfully pass the values from the listbox control to a
|
by: Enyi |
last post by:
Just like my last post I cannot solve this problem with a stored procedure in MSSQL Server 2000 Developer Edition.
I am trying to use the parameter in VB.NET 2003.
When I run the VB code and execute the stored procedure, the exact error message is: "Parameter1 is not a parameter for procedure EditCustomer."
The only thing is it is a parameter for the procedure. I would appreciate any help with this one. Most probably an obvious, simple...
|
by: serge |
last post by:
/*
Subject: How to build a procedure that returns different
numbers of columns as a result based on a parameter.
You can copy/paste this whole post in SQL Query Analyzer
or Management Studio and run it once you've made sure
there is no harmful code.
Currently we have several stored procedures which final
result is a select with several joins that returns many
|
by: Routergal |
last post by:
Dear SQL gurus,
I am so new at this, as a matter of fact this is my first Access Database front-end with a SQL back-end. I wrote a stored procedure to show liability for vacation accrued:
SELECT dbo.PS_PERSONAL_DATA.EMPLID, dbo.PS_PERSONAL_DATA.NAME, PS_PERSONAL_DATA_1.NAME AS SUPERVISOR_NAME, SUM(dbo.PS_JOB.HOURLY_RT * dbo.Vac_Accrued1.Total_Vac_Earned + dbo.Floater_Balance.Total_Floater_Balance) AS Liability
FROM ...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |