OUTPUT Paramater From Stocked Procedure Sent To SDS Not Working

Mar 16, 2007

Juste have fun with the following, if you can manage this out your my savior, been wasting far too much time on it, tried a couple of method and none ever worked.


Conversion from type 'DBNull' to type 'String' is not valid.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.
Source Error:





Line 105:
Line 106: Protected Sub sdsProprActionAJO_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles sdsProprActionAJO.Inserted
Line 107: Dim MessageSysteme As String = CType((CType(e.Command.Parameters("SQL_MSG"), IDbDataParameter)).Value, String)
Line 108: End Sub
Line 109: 
         With sdsProprActionAJO
            .ConnectionString = ConfigurationManager.AppSettings("DB_CS_MSSQL")

            .InsertCommandType = SqlDataSourceCommandType.StoredProcedure
            .InsertCommand = "dbo.sp_adm_cartListe"

            .InsertParameters.Clear()
            .InsertParameters.Add("Mode", TypeCode.String, "SEL")
            .InsertParameters.Add("LPR_Groupe", TypeCode.String, CBool(CType(Me.pnlProprActionAJO.FindControl("rblProprActionAJOGroupe"), RadioButtonList).SelectedValue))
            .InsertParameters.Add("LPR_Etiquette", TypeCode.String, CType(Me.pnlProprActionAJO.FindControl("tbProprActionAJOEtiquette"), TextBox).Text)

            .Insert()
        End With
    End Sub

    Protected Sub sdsProprActionAJO_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles sdsProprActionAJO.Inserted
        Dim MessageSysteme As String = CType((CType(e.Command.Parameters("SQL_MSG"), IDbDataParameter)).Value, String)
    End Sub

    Protected Sub sdsProprActionAJO_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles sdsProprActionAJO.Inserting
        Dim Param As System.Data.SqlClient.SqlParameter = New System.Data.SqlClient.SqlParameter()
        param.DbType = DbType.String
        param.Direction = ParameterDirection.Output
        param.ParameterName = "SQL_MSG"

        e.Command.Parameters.Add(Param)
    End Sub
 CREATE PROCEDURE [dbo].[sp_Adm_Proprietes_AJO]
(
@MODE        VARCHAR(3),
@LPR_Groupe        BIT = NULL,
@LPR_Etiquette    NVARCHAR(32) = NULL,
@RPP_LPR_IdParent    [INT] = NULL,
@RPP_LPR_IdEnfant    [INT] = NULL,
@SQL_MSG        NVARCHAR(8)  OUTPUT
)

AS
--

DECLARE @SQL_TEMP NVARCHAR(4000)
DECLARE @INT_TEMP [INT]

--

IF @MODE = 'RRP'
BEGIN
    INSERT INTO t__REL__PropParent_PropEnfant (
        RPP_LPR_IdParent,
        RPP_LPR_IdEnfant
    ) VALUES (
        @RPP_LPR_IdParent,
        @RPP_LPR_IdEnfant
    )
END

--


IF @MODE = 'LPR'
BEGIN
    IF NOT @LPR_Etiquette = NULL
        BEGIN
        SELECT * FROM t_Lib_Proprietes  WHERE (LPR_Groupe = @LPR_Groupe ) AND (LPR_Etiquette = @LPR_Etiquette )
    
        IF @@ROWCOUNT <= 0
        BEGIN
            INSERT INTO t_Lib_Proprietes (
                LPR_Groupe,
                LPR_Etiquette
            ) VALUES (
                @LPR_Groupe,
                @LPR_Etiquette
            )
            SET @SQL_MSG = 'CON_000A'
        END
        ELSE
        BEGIN
            SET @SQL_MSG = 'ERR_000A'
        END
    END
    ELSE
    BEGIN
        SET @SQL_MSG = 'ERR_003A'
    END
END

RETURN @SQL_MSG
GO


 

View 8 Replies


ADVERTISEMENT

Using Output Paramater

Nov 5, 2007

Hi all
         In my application i have to upload a excel file.After that it will retrive tha data from database depending upon the data in excel sheet.So now the problem is that i am using a stored procedure for this and in that procedurei have taken output parameter to catch any type of error.For example suppose in my excel sheet i have 3 columns.let it Group Code,Employee No and Employee Code.So incase it will not find the employee number so using the output parameter i am throwing the error message.So here we are getting two return types.one is the selected data and another is the error message.So how to handle these two thing in asp.net.Usong a dataset i can only retrive the selected data.But how to get the errror message as well as the data.So please help me.

View 1 Replies View Related

Retrieving Output Paramater After Insert

Sep 14, 2006

Can some one offer me some assistance? I'm using a SQLDataSource control to call a stored proc to insert a record into a control.  The stored proc I'm calling has an output paramater that returns the new rows identity field to be used later.  I'm having trouble getting to this return value via the SQLDataSource .  Below is my code (C#): SqlDataSource1.InsertParameters["USR_AUTH_NAME"].DefaultValue = storeNumber;SqlDataSource1.InsertParameters["usr_auth_pwd"].DefaultValue = string.Empty;SqlDataSource1.InsertParameters["mod_usr_name"].DefaultValue = "SYSTEM";SqlDataSource1.InsertParameters["usr_auth_id"].Direction = ParameterDirection.ReturnValue;SqlDataSource1.Insert();int id = int.Parse(SqlDataSource1.InsertParameters["usr_auth_id"].DefaultValue); below is the error I'm getting: System.Data.SqlClient.SqlException: Procedure 'csi_USR_AUTH' expects parameter '@usr_auth_id', which was not supplied. Has anyone done this before and if so how did you do it?

View 1 Replies View Related

SPROC Output Paramater Asking For Input?

Jan 3, 2008

I am trying to get a stored proceedure to return the autogenerated numerical primary key of the last row created to our appliciation. I have created what I thought was an output parameter to handle this however when the application runs I get a message that seems to indicate that it is ASKING for the parameter instead of returning it. Here is the code of the sproc:




Code Block
USE [chronicle]
GO
/****** Object: StoredProcedure [dbo].[CreateNewLicense] Script Date: 01/03/2008 06:35:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CreateNewLicense]

@VendorId int,
@PoId int,
@LicenseTypeId int,
@LicenseUserId int,
@LocationId int,
@LicenseStartDate smalldatetime,
@DaysAllowed int,
@SerialNum varchar(50),
@ActivationKey varchar(50),
@MaxUsers int,
@Comments varchar(1000),
@LicenseId int OUTPUT
AS
BEGIN
INSERT INTO license
(vendor_id,
po_id,
license_type_id,
lic_user_id,
location_id,
lic_start_date,
days_allowed,
serial_num,
activation_key,
max_users,
comments
)
VALUES
( @VendorId,
@PoId,
@LicenseTypeId,
@LicenseUserId,
@LocationId,
@LicenseStartDate,
@DaysAllowed,
@SerialNum,
@ActivationKey,
@MaxUsers,
@Comments
)
SELECT @LicenseId = @@IDENTITY
END





View 5 Replies View Related

Character Limit For Variables Inside A Stocked Procedure

Feb 23, 2007

I am currently having a problem where my SQL server seems to lock any variables to 1000 characters (ie. varchar(8000) can only hold 1000)I have read in numerous sources it was possible to change that limit so the varchar can truly hold the 8000 characters and not stop at 1000, but there was no info on how to do this.I am looking for a "How to" to put this limit to 8000.Thank you! 

View 10 Replies View Related

How To Pass Parameters In Url For A Report Published In Reportserver (report Built On Stocked Procedure) ?

Apr 30, 2007

Hi,



I have created a report with the report server project template.

the report is created from stoked procedure having defaut input parameters.

With visual studio, i publish my report on reportserver. whenever i access to my report on this url :

http://localhost/ReportServer/Pages/ReportViewer.aspx?%2fReport+Project4%2fReport4&rs:Command=Render. the created report is with the default parameters.



I would like to know if i can transmet parameters for the stocked procedure to build the report with the request i want.


I tried to put parameter directly in the url in this way

http://localhost/ReportServer/Pages/ReportViewer.aspx?%2fReport+Project4%2fReport4&rs:Command=Render&@region='toto'

but without success.

my error message is that one

An attempt was made to set a report parameter '@region' that is not defined in this report. (rsUnknownReportParameter)





My stocked procedure is :

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[akli] @region varchar ='m'
as
select * from dbo.Report2 where region=@region

The request used to buid the report ?
DECLARE @region varchar
EXECUTE dbo.akli @region


What is wrong in that ?

Thanks for your help.

Arioule

View 1 Replies View Related

I Am Passing A Stored Procedure A Paramater...how Do I

May 22, 2000

make it so that I compare that parameter, that is a char(3), to something like "XXX" and then choose the correct SELECT statement to use depending on that parameter.... much like an if else.

Any help is GREATLY appreciated. Thanks.

Robert

View 1 Replies View Related

Stored Procedure Sebquery As A Paramater

Jul 23, 2005

Ok,This sounds dangerous (and yes I know it is)But its in a controlled enviroment and I really need to know how to dothis.How can I pass a Subquery for an Exist or In clause as a paramaterSomething like thisCREATE procedure dbo.mytry@funk varchar(1000)asSelect * from Customers where exists(@funk)GOSo I would execute something like soexec mytry @funk='Select ID From Customers where ID < 100'Any Ideas, I have tried LOTS of things but I can actually get it towork.I need to use it conjunction with a 3rd party product that can onlyselect from a Stored Procedure, and I can only pass paramaters to theSP.Any suggestions ?ThanksChris

View 6 Replies View Related

How To Pass Table Name As Paramater In Stored Procedure

Feb 5, 2008

I am using SQL2005 and would like to know if it is possible to pass a table name as an input parameter in a stored procedure?? I am struggling to get it to work.

For example:

CREATE PROCEDURE dbo.StartBlock

@TableName varchar(30),

@minX float OUTPUT,



AS



BEGIN

SET NOCOUNT ON;





SET @minX = (SELECT min(X) as mX

FROM @TableName);



END

GO

The above does not work and give the following error

Must declare the table variable "@TableName"

Thanks
Christie

View 5 Replies View Related

Transact SQL :: Generic Store Procedure Call Without Output Parameters But Catching Output

Sep 21, 2015

Inside some TSQL programmable object (a SP/or a query in Management Studio)I have a parameter containing the name of a StoreProcedure+The required Argument for these SP. (for example it's between the brackets [])

EX1 : @SPToCall : [sp_ChooseTypeOfResult 'Water type']
EX2 : @SPToCall : [sp_ChooseTypeOfXMLResult 'TABLE type', 'NODE XML']
EX3 : @SPToCall : [sp_GetSomeResult]

I can't change thoses SP, (and i don't have a nice output param to cach, as i would need to change the SP Definition)All these SP 'return' a 'select' of 1 record the same datatype ie: NVARCHAR. Unfortunately there is no output param (it would have been so easy otherwise. So I am working on something like this but I 'can't find anything working

DECLARE @myFinalVarFilledWithCachedOutput 
NVARCHAR(MAX);
DECLARE @SPToCall NVARCHAR(MAX) = N'sp_ChooseTypeOfXMLResult
''TABLE type'', ''NODE XML'';'
DECLARE @paramsDefintion = N'@CatchedOutput NVARCHAR(MAX) OUTPUT'

[code]...

View 3 Replies View Related

Using Output From A Stored Procedure As An Output Column In The OLE DB Command Transformation

Dec 8, 2006

I am working on an OLAP modeled database.

I have a Lookup Transformation that matches the natural key of a dimension member and returns the dimension key for that member (surrogate key pipeline stuff).

I am using an OLE DB Command as the Error flow of the Lookup Transformation to insert an "Inferred Member" (new row) into a dimension table if the Lookup fails.

The OLE DB Command calls a stored procedure (dbo.InsertNewDimensionMember) that inserts the new member and returns the key of the new member (using scope_identity) as an output.

What is the syntax in the SQL Command line of the OLE DB Command Transformation to set the output of the stored procedure as an Output Column?

I know that I can 1) add a second Lookup with "Enable memory restriction" on (no caching) in the Success data flow after the OLE DB Command, 2) find the newly inserted member, and 3) Union both Lookup results together, but this is a large dimension table (several million rows) and searching for the newly inserted dimension member seems excessive, especially since I have the ID I want returned as output from the stored procedure that inserted it.

Thanks in advance for any assistance you can provide.

View 9 Replies View Related

Output Parameter In SP Not Working?

Feb 28, 2008

Hi everyone,
   This is the sp i have written which works fine in the sql server management studio when i run it but when i call it from the vb.net web application the output parameters are generated as nothing but the sp return the data from the select statement, so here is the sp followed by vb.net code to access the sp. 
This is the Store ProcedureCREATE PROCEDURE [dbo].StaffAuthenticate
@Staff_ID nvarchar(50),
@Password nvarchar(15),
@IsAuthenticated int OUTPUT,
@P_message_code int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
Select * From Staff;
SET @IsAuthenticated = 0;
SET @P_message_code = 100;
RETURN END
GOThis is the VB.NET code.  Dim ConStr As String = GenericDataAccess.GetConnection(IConnectionStrNames.OAAStaffAuthStr)
Dim Conn As SqlConnection = New SqlConnection(ConStr)
Dim Command As SqlCommand = Nothing
Conn.Open()
Command = New SqlCommand()
Command.Connection = Conn
Command.CommandText = "StaffAuthenticate"
Command.CommandType = CommandType.StoredProcedure

Command.Parameters.Add("@Staff_ID", SqlDbType.NVarChar, 50).Value = UserId
Command.Parameters.Add("@Password", SqlDbType.NVarChar, 15).Value = Password
Command.Parameters.Add("@IsAuthenticated", SqlDbType.Int).Direction = ParameterDirection.Output
Command.Parameters.Add("@P_message_code", SqlDbType.Int).Direction = ParameterDirection.Output

Dim myDataReader As SqlDataReader = Command.ExecuteReader()
Dim Res As New StringBuilder

While (myDataReader.Read())
For i As Integer = 0 To myDataReader.FieldCount - 1
Res.Append(myDataReader(i).ToString())
Res.Append(" ; ")
Next
Res.AppendLine()
End While

MsgBox(Command.Parameters("@IsAuthenticated").Value)
MsgBox(Command.Parameters("@P_message_code").Value)
MsgBox(Res.ToString, MsgBoxStyle.Information, "DAL : StaffSqlAuthenticate")  Thanks for all the help, Really could use one. Kabir 
 

View 5 Replies View Related

Why Is My Output Parameter Not Working?

Jul 23, 2005

Hi,I am currently creating an ASP page that returns a recordset of searchresult based on multiple keywords. The where string is dynamicallybuilt on the server page and that part work quite well. However I wantto also return the number of records in the recordset and I can notmanage to get any output parameter working. Even if I assign SELECT@mycount=100 (or SET @mycount=100) in the SP the only value set inmycount is always NULL. I tested various theories (e.g. early exit,order & naming of parameters etc. but I can not make the SP set theoutput parameters - has it anything to do with the execute?). @mycountalso returns NULL if I test it in SQL QA.What's wrong with this SP (as regards mycount):CREATE PROCEDURE dbo.spFindProducts@mycount integer OUTPUT,@whereString varchar (1000)AS--SET NOCOUNT ON--Set a Default value for the Wherestring which will return all recordsif the Wherestring is blankIF @whereString is NullSELECT @whereString = 'AND TblProduct.ProductID is not null'--Declare a variable to hold the concatenated SQL stringDECLARE @SQL varchar(2500)-- AND (((UPPER([TblProduct].[ProductName] + [ProductGroupCode] +[AttributeValue1] +-- [SearchWords] + [tblSupplier].[SupplierCode] + [SupplierDesc]))Like '%screw%'))SELECT @SQL = 'SELECT TblProduct.ProductID, TblProduct.ProductName,TblProduct.ChapterCode, tblProduct.ProductGroupCode' +' FROM (TblProduct LEFT JOIN TblStockItem ON TblProduct.ProductID =TblStockItem.ProductID) ' +' LEFT JOIN tblSupplier ON TblProduct.SupplierCode =tblSupplier.SupplierCode' +' WHERE 1=1 ' + @whereString +' GROUP BY TblProduct.ProductID, TblProduct.ProductName,TblProduct.ChapterCode, TblProduct.ProductGroupCode'SELECT @mycount = 200; -- testexecute (@SQL);-- next line seems to be ignored ?SELECT @mycount = @@rowcount;GOtiaAxel

View 11 Replies View Related

SqlCommand Return And Output Parameters Not Working, But Input Does?

Feb 18, 2006

The foolowing code I cannot seem to get working right. There is an open connection c0 and a SqlCommand k0 persisting in class.The data in r0 is correct and gets the input arguments at r0=k0->ExecuteReader(), but nothing I do seems to get the output values. What am I missing about this?

System::Boolean rs::sp(System::String ^ ssp){

System::String ^ k0s0; bool bOK;

System::Data::SqlClient::SqlParameter ^ parami0;

System::Data::SqlClient::SqlParameter ^ parami1;

System::Data::SqlClient::SqlParameter ^ parami2;

System::Data::SqlClient::SqlParameter ^ paramz0;

System::Data::SqlClient::SqlParameter ^ paramz1;

System::Int32 pz0=0;System::Int32 pz1=0;

k0s = ssp;

k0->CommandType=System::Data::CommandType::StoredProcedure;

k0->CommandText=k0s;

paramz0=k0->Parameters->Add("@RETURN_VALUE", System::Data::SqlDbType::Int);

//paramz0=k0->Parameters->AddWithValue("@RETURN_VALUE",pz0);

//paramz0=k0->Parameters->AddWithValue("@RETURN_VALUE",pz0);

paramz0->Direction=System::Data::ParameterDirection::ReturnValue;

paramz0->DbType=System::Data::DbType::Int32;

parami0=k0->Parameters->AddWithValue("@DESCXV","chicken");

parami0->Direction=System::Data::ParameterDirection::Input;

parami1=k0->Parameters->AddWithValue("@SRCXV","UU");

parami1->Direction=System::Data::ParameterDirection::Input;

//paramz1=k0->Parameters->AddWithValue("@RCOUNT",pz1);

paramz1=k0->Parameters->Add("@RCOUNT",System::Data::SqlDbType::Int);

paramz1->Direction=System::Data::ParameterDirection::InputOutput;

paramz0->DbType=System::Data::DbType::Int32;

//k0->Parameters->GetParameter("@RCOUNT");

r0=k0->ExecuteReader();

//pz0=System::Convert::ToInt32(paramz0->SqlValue);

bOK=k0->Parameters->Contains("@RCOUNT");

//k0->Parameters->GetParameter("@RCOUNT");

pz0=System::Convert::ToInt32(paramz0->Value);

pz1=System::Convert::ToInt32(paramz1->Value);

ndx = -1;

while(r0->Read()){

if (ndx == -1){

ndx=0;

pai0ndx=0;

pad0ndx=0;

r0nf=r0->FieldCount::get();

for (iG1_20=0;iG1_20<r0nf;iG1_20++){

this->psf0[iG1_20]=this->r0->GetName(iG1_20);

this->psv0[iG1_20]=this->r0->GetDataTypeName(iG1_20);

this->psz0[iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

this->pas0[ndx,iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

if (psv0[iG1_20]=="int") {pai0[ndx,pai0ndx]=System::Convert::ToInt32(r0->GetValue(iG1_20));pai0ndx++;}

if (psv0[iG1_20]=="float") {pad0[ndx,pad0ndx]=System::Convert::ToDouble(r0->GetValue(iG1_20));pad0ndx++;}

}



}

else {

pai0ndx=0;

pad0ndx=0;

for (iG1_20=0;iG1_20<r0nf;iG1_20++)

{ this->pas0[ndx,iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

if (psv0[iG1_20]=="int") {pai0[ndx,pai0ndx]=System::Convert::ToInt32(r0->GetValue(iG1_20));pai0ndx++;}

if (psv0[iG1_20]=="float") {pad0[ndx,pad0ndx]=System::Convert::ToDouble(r0->GetValue(iG1_20));pad0ndx++;}

}

}

ndx++;

}

r0nr=ndx;

r0->Close();

k0->Parameters->Remove(paramz0);

k0->Parameters->Remove(parami1);

k0->Parameters->Remove(parami0);

k0->Parameters->Remove(paramz1);

return true;

}

View 5 Replies View Related

Calling A Stored Procedure From ADO.NET 2.0-VB 2005 Express: Working With SELECT Statements In The Stored Procedure-4 Errors?

Mar 3, 2008

Hi all,

I have 2 sets of sql code in my SQL Server Management Stidio Express (SSMSE):

(1) /////--spTopSixAnalytes.sql--///

USE ssmsExpressDB

GO

CREATE Procedure [dbo].[spTopSixAnalytes]

AS

SET ROWCOUNT 6

SELECT Labtests.Result AS TopSixAnalytes, LabTests.Unit, LabTests.AnalyteName

FROM LabTests

ORDER BY LabTests.Result DESC

GO


(2) /////--spTopSixAnalytesEXEC.sql--//////////////


USE ssmsExpressDB

GO
EXEC spTopSixAnalytes
GO

I executed them and got the following results in SSMSE:
TopSixAnalytes Unit AnalyteName
1 222.10 ug/Kg Acetone
2 220.30 ug/Kg Acetone
3 211.90 ug/Kg Acetone
4 140.30 ug/L Acetone
5 120.70 ug/L Acetone
6 90.70 ug/L Acetone
/////////////////////////////////////////////////////////////////////////////////////////////
Now, I try to use this Stored Procedure in my ADO.NET-VB 2005 Express programming:
//////////////////--spTopSixAnalytes.vb--///////////

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim sqlConnection As SqlConnection = New SqlConnection("Data Source = .SQLEXPRESS; Integrated Security = SSPI; Initial Catalog = ssmsExpressDB;")

Dim sqlDataAdapter As SqlDataAdapter = New SqlDataAdaptor("[spTopSixAnalytes]", sqlConnection)

sqlDataAdapter.SelectCommand.Command.Type = CommandType.StoredProcedure

'Pass the name of the DataSet through the overloaded contructor

'of the DataSet class.

Dim dataSet As DataSet ("ssmsExpressDB")

sqlConnection.Open()

sqlDataAdapter.Fill(DataSet)

sqlConnection.Close()

End Sub

End Class
///////////////////////////////////////////////////////////////////////////////////////////

I executed the above code and I got the following 4 errors:
Error #1: Type 'SqlConnection' is not defined (in Form1.vb)
Error #2: Type 'SqlDataAdapter' is not defined (in Form1.vb)
Error #3: Array bounds cannot appear in type specifiers (in Form1.vb)
Error #4: 'DataSet' is not a type and cannot be used as an expression (in Form1)

Please help and advise.

Thanks in advance,
Scott Chang

More Information for you to know:
I have the "ssmsExpressDB" database in the Database Expolorer of VB 2005 Express. But I do not know how to get the SqlConnection and the SqlDataAdapter into the Form1. I do not know how to get the Fill Method implemented properly.
I try to learn "Working with SELECT Statement in a Stored Procedure" for printing the 6 rows that are selected - they are not parameterized.




View 11 Replies View Related

How Do I Pass A Paramater?

Oct 19, 2006

Hey everyone I'm having trouble finding a way to pass a particular paramater, my main goal of this is to create a custom paging and sorting control for the DataList, but we wont worry about all the un-nessesarry code, here is what I am dealing with... Sub Page_Load()

Dim Conn As SqlConnection
Dim Query As String
Dim SqlComm As SqlCommand
Dim myDataReader As SqlDataReader

' Define connection object
Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

' Define query to retrieve main category values
Query = "SELECT [productMainCategory] FROM [User_Products] WHERE [productMainCategory] = @productMainCategory"
' Define command object
SqlComm = New SqlCommand(Query, Conn)

' Open connection to database
Conn.Open()

' Create DataReader
myDataReader = SqlComm.ExecuteReader()

' Iterate through records and add to array list
While myDataReader.Read()
IDList.Add(myDataReader("productMainCategory"))
End While

' Close DataReader and connection objects
myDataReader.Close()
myDataReader = Nothing
Conn.Close()
Conn = Nothing

' If page has not been posted back, retrieve first page of records
If Not Page.IsPostBack Then
Paging()
End If

End Sub
The Entire Point to this bit of code is to open a connection to the database find the category productsMainCategory, count all the fields with the Name 3D Art --> and save that number into an Array List where I will be using it later on in my code......The big old problem here is that it counts every single field in the productsMainCategory, Columb.........I need to figure out how to pass it a parameter so that it only counts my 3D Art --> fields, I have tried using this bit of code but nothing             SqlComm.Parameters("@productMainCategory").Value = "3D Art --&gt;"Does anyone have any ideas of how I might go about donig this?Thank You..

View 4 Replies View Related

How Can I Return Everything While Using A Paramater

Jun 26, 2007

I guess a pretty basic sql question here. I am using tableadapters. And some of the queries have multiple parameters. But often a parameter is at a default or null - wherein I'd like to be able to pass it in and have it not filter at all - ie., return everything.
Simple example:
Select * from ReportsWhere ReportID = @ReportID 
 If I have a dropdownlist of reports where the values are ReportIDs - but the topmost unselected value is say "", then the results will be generated by
Select * from ReportsWhere ReportID = ''
Whis not what I want. What I would want is simply
Select * from Reports
or
Select * from ReportsWhere ReportID = ReportID
So how can one setup say an ObjectDataSource or somehow handle this where I don't need to use dynamic sql to expand/contract my where clause?
Really need hlpe on this and hope I've made my question reasonably clear. Thanks.
 
 

View 3 Replies View Related

Trigger And Paramater

May 24, 2004

is possible for a trigger to check a particular record by passing a parameter during an update event?

if yes, what is the syntax?

View 3 Replies View Related

Parce A Db Paramater / Value

Apr 20, 2007

I need to parce a criteria in the data base
I have a field/colum in my tbl1 call invoice_num
I am left joining to to site_id on tbl2.
how can i talk tbl1 invoice_num and parce it to add in numbers.

IE tbl1.invoice _num is AF3456 and in order to match it to tbl2.site_id I need to add a 0 so that it would be AF03456 or AF034560.

Hope i did not loose you on this question.

View 2 Replies View Related

Multiple Paramater Search

Sep 23, 2005

I have a search page, containing 3 drop down lists. Theses are used to match data in 3 seperate collumns of a table.I can get the search to work when all boxes are completed, but I need to be able to leave some blank.A similar question was asked in http://forums.asp.net/626941/ShowPost.aspxAnd a very good solution was give: http://www.sqlteam.com/item.asp?ItemID=2077But I don't seem to be able to get any of these examples working!If I use the SET @SQL method, I get an error message saying that my input parameter has not been declared, when it has.When I use the COALESCE method, there is no data returned.(I am passing the data drop down list data fin the search page through the query string to a results page).Does anyone know of any other examples, or sample coding??Thanks...

View 2 Replies View Related

Removing A Paramater Gives An Error

Feb 6, 2006





Removing a parameter on a Reporting services report based on a 2005 AS cube results in an error:

[rsParameterReference] The Value expression for the query parameter €˜KalenderHierarchieJaarMaand€™ refers to a non-existing report parameter €˜KalenderHierarchieJaarMaand€™.

On the dataset, the parameter still exists. The error still occors after removing the parameter overhere too.

Steps to reproduce:

Build a raport based on a cube. Make a parameter in the dataset. check if the parameter works. Save the report and remove the parameter via the menu: Report> Report parameters > select the parameter and choose [Remove]. go to the "Preview" tab.

Has anyone found a work-around for this?

Thanks in advance,

Pieter

View 2 Replies View Related

Ora-12645 Paramater Does Not Exist

Apr 24, 2007

I get the ora-12645 error when doing an import from oracle to mssql. The error comes-up when setting up the datalink properties of the source database which is oracle. This error happens on a 2003 server machine using the import/export wizard. It works fine when using an xp machine.

any ideas?

View 19 Replies View Related

Deselect All On Multivalue Paramater When Other Value Is Chosen

Dec 26, 2007



I use "All" as default value in my parameters, my parameters are multivalue.
Now if a user chooses a value it will mark the value but the All will also remain marked. Isn't there a way that it deselects the all when one or more individual values are chosen ?

I thought that the reporting services just didn't have that functionality but someone told me that its possible but i haven't found it anywhere.

View 3 Replies View Related

To Use Multiple Value Paramater In The IN List Of A Where Clause

Jan 8, 2008

I have a parent and child package. i pass a parent package variable called @abc with a value of (1,2,3,4,5,6) to the child package. here in the oledb source i have a select statement like,
select *
from A
where id in (@abc)

It gives me an error. any way to make this work.

View 14 Replies View Related

Paramater Use For Both Relational And Analysis Services?

Nov 9, 2007



Does anyone know if it is possible to have one parameter that is used for both a relational(SQL) and Analysis Services(MDX) query within one report? I need to pull up-to-date inventory counts for a product, which are not in my Analysis Services cube I also have related Product information in Analysis Services that I need in the same report. I can't seem to find any information about how to do this or if it is even possible...

Frank

View 3 Replies View Related

Procedure Not Working

Dec 1, 2005

EDIT:

Hey guys sorry for posting in the wrong forum.

Thanks for the links.

View 5 Replies View Related

Passing In Query Paramater Values Through WebUserControls

Jun 7, 2007

Hi, I don't want to pass in parameter values in the url to get a certain record from my database (for a better search engine result) so instead i'm using webuser controls (this is a must) with Public Values that should be read by the SqlDataSource. So in the page that contains the usercontrol there is something like:UserControl.Value = "myvalue"Now I want the SqlDataSource in the usercontrol to read this value and pass it into a query (in the parameter of the WHERE statement, eg.: @recordID = myvalue).Thanks in advance! 

View 1 Replies View Related

New To SSRS - Pass Query Paramater At Runtime

Jun 21, 2007

Hi all,

Im new to SSRS, basically I have created and deployed a report to my reporting server.

Now I have a query parameter on my report. From my application, I can access the report manager, and here it asks me for my variable. I'm not sure if my question is a vb.net one, but I was wondering if anyone knew how I could pass my query paramater to SSRS at runtime. Basically it would be easier for my users if they could just see the report they are interested in, rather than having to type the variable in to be able to see the report.

Thanks for your time.
Pace

"Impossible is Nothing"

View 1 Replies View Related

New To SSRS - Pass Query Paramater At Runtime

Jun 21, 2007

Hi all,

Im new to SSRS, basically I have created and deployed a report to my reporting server.

Now I have a query parameter on my report. From my application, I can access the report manager, and here it asks me for my variable. I'm not sure if my question is a vb.net one, but I was wondering if anyone knew how I could pass my query paramater to SSRS at runtime. Basically it would be easier for my users if they could just see the report they are interested in, rather than having to type the variable in to be able to see the report.

Thanks for your time.
Barry Andrew

View 3 Replies View Related

Help Stored Procedure Working But Not Doing Anything

Jul 31, 2006

Help Stored procedure working but not doing anything New Post
Quote    Reply
Please i need some help.

I am calling a stored procedure from  asp.net and there is a
cursor in the stored procedure that does some processing on serval
tables.

if i run the stored procedure on Query Analyzer it works and does what
it is suppose to do but if i run it from my asp.net/module control it
goes. acts likes it worked but it does not do what is suppose to do.
i believe the cursor in the stroed procedure does not run where is
called programmatically from the asp.net/module control page.plus it
does not throw any errors


This is the code from my control
System.Data.SqlClient.SqlParameter [] param={new
System.Data.SqlClient.SqlParameter("@periodStart",Convert.ToDateTime(startDate)),new
System.Data.SqlClient.SqlParameter("@periodStart",Convert.ToDateTime(endDate)),new
System.Data.SqlClient.SqlParameter("@addedby",UserInfo.FullName+ "
"+UserInfo.Username)};
               
string
str=System.Configuration.ConfigurationSettings.AppSettings["payrollDS"];
               
System.Data.SqlClient.SqlConnection cn=new
System.Data.SqlClient.SqlConnection(str);
               
cn.Open();              

               
//System.Data.SqlClient.SqlTransaction trans=cn.BeginTransaction();

               
SqlHelper.ExecuteScalar(cn,System.Data.CommandType.StoredProcedure,"generatePaylistTuned",param);
      


------------------------THis is the code for my storedprocedure-------------

CREATE PROCEDURE [dbo].[generatePaylistTuned]
@periodStart datetime,
@periodEnd datetime,
@addedby varchar(40)

AS

begin transaction generatePayList

DECLARE @pensioner_id int, @dateadded datetime,
 @amountpaid float,
@currentMonthlypension float,@actionType varchar(50),
@isAlive bit,@isActive bit,@message varchar(80),@NoOfLoadedPensioners int,
@NoOfDeadPensioners int,@NoOfEnrolledPensioners int,@DeactivatedPensioners int,
@reportSummary varchar(500)

set @NoOfLoadedPensioners =0

set @NoOfDeadPensioners=0
set @NoOfEnrolledPensioners=0
set @DeactivatedPensioners=0
set @actionType ="PayList Generation"

DECLARE paylist_cursor CURSOR FORWARD_ONLY READ_ONLY FOR

select p.pensionerId,p.isAlive,p.isActive,py.currentMonthlypension
from pensioner p left outer join pensionpaypoint py on  p.pensionerid=py.pensionerId

where p.isActive = 1


OPEN paylist_cursor

FETCH NEXT FROM paylist_cursor
INTO @pensioner_id,@isAlive,@isActive,@currentMonthlypension

WHILE @@FETCH_STATUS = 0
BEGIN

set @NoOfLoadedPensioners=@NoOfLoadedPensioners+1
if(@isAlive=0)
begin
update Pensioner
set isActive=0
where pensionerid=@pensioner_id
set @DeactivatedPensioners =@@ROWCOUNT+@DeactivatedPensioners
set @NoOfDeadPensioners =@@ROWCOUNT+@NoOfDeadPensioners
end
else
begin
insert into pensionpaylist(pensionerId,dateAdded,addedBy,
periodStart,periodEnd,amountPaid)
values(@pensioner_id,getDate(),@addedby, @periodStart, @periodEnd,@currentMonthlypension)
set @NoOfEnrolledPensioners =@@ROWCOUNT+ @NoOfEnrolledPensioners
end

   -- Get the next author.
   FETCH NEXT FROM paylist_cursor
   INTO  @pensioner_id,@isAlive,@isActive,@currentMonthlypension
END

CLOSE paylist_cursor
DEALLOCATE paylist_cursor

set @reportSummary ="The No. of Pensioners Loaded:
"+Convert(varchar,@NoOfLoadedPensioners)+"<BR>"+"The No. Of
Deactivated Pensioners:
"+Convert(varchar,@DeactivatedPensioners)+"<BR>"+"The No. of
Enrolled Pensioners:
"+Convert(varchar,@NoOfEnrolledPensioners)+"<BR>"+"No Of Dead
Pensioner from Pensioners Loaded: "+Convert(varchar,@NoOfDeadPensioners)
insert into reportSummary(dateAdded,hasExceptions,periodStart,periodEnd,reportSummary,actionType)
values(getDate(),0, @periodStart, @periodEnd,@reportSummary,'Pay List Generation')

 if (@@ERROR <> 0)               
          BEGIN

insert into reportSummary(dateAdded,hasExceptions,periodStart,periodEnd,reportSummary,actionType)
values(getDate(),1, @periodStart,@periodEnd,@reportSummary,'Pay List Generation')

ROLLBACK TRANSACTION  generatePayList

          END

commit Transaction generatePayList
GO

View 5 Replies View Related

Remote Procedure Is Not Working

Jul 28, 1999

Hi We have SQL6.5 servers with serpack3. I have registered the remote sql servers on both sqlservers. I have login name as same and trusted.(by the way I did this through GUI)
when I run a remote procedure it comes and tell me
**********************************************

DB-Library: Unexpected EOF from SQL Server. General network error. Check your documentation.
Net-Library error 10054: ConnectionCheckForData ((null)()).

DB-Library Process Dead - Connection Broken

*************************************************
???????
in some servers I did the same configuration it works fine.
All the servers are configured Uniqly. Protocols and dblib were same.

Can anyone Please...Please>>please explain how to configure this or is there any other way to execute a remote procedure.......?????
I really, infact really appreciate any help regarding this.
Thanks a lot.

Mini

View 1 Replies View Related

Alter Procedure Not Working

May 20, 2008


we use alter statements for our stored procedures when rolling out a new version of our app. We have noticed that when viewing the stored proc in production it looks like the altered one, but when the app runs it, the changes are not taking effect. Has any one else experienced anything like this? It's like the old version is still being held on too.

To get around the problem we have been dropping and recreating the procedures.

Any help would be appreciated. Thanks!

View 1 Replies View Related

Output Stored Procedure

Oct 18, 2006

 1 public static List<string> viewtree(int root)
2 {
3 SqlConnection con = new SqlConnection(mainConnectionString);
4 con.Open();
5 try
6 {
7 List<string> ids = new List<string>();
8 SqlCommand command = new SqlCommand(@"ShowHierarchy2", con);
9 command.Parameters.AddWithValue("@root", root);
10 command.Parameters.Add(new SqlParameter("@outstring", SqlDbType.VarChar));
11 command.Parameters["@outstring"].Direction = ParameterDirection.Output;
12 command.CommandType = CommandType.StoredProcedure;
13 //command.ExecuteScalar();
14 //ids = command.Parameters["@outstring"].Value.ToString();
15
16 SqlDataReader dr = command.ExecuteReader();
17 while (dr.Read())
18 {
19 ids.Add((dr["@outstring"].ToString()));
20 }
21 //command.Parameters.Clear();
22
23 return ids;
24 }
25 finally
26 {
27 con.Close();
28 }
29 }
 Can someone tell me why i'm getting the following error:String[1]: the Size property has an invalid size of 0. Thanks in advance

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved