SQL Server :: What If Multiple Output Parameters And Input Parameters And Also Want A Select Table

Feb 16, 2011

[Code]....

When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no rows.is it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.

[code]....

View 8 Replies


Similar Messages:

Web Forms :: Input And Output Parameters For Stored Procedures In VB.NET?

Oct 22, 2010

I have several VB.NET functions which pass and receive values from executed stored procedures using parameters. However, the latest method I am using seems to be a little too specific on the datatype and data length of the parameters for my liking (i.e.

LogActivityCommand.Parameters.Add("@strErrSource", SqlDbType.NVarChar, 300).Value = strErrSource). For example:

[code]....

If I end up changing the datatype and data length properties of the variables in my SQL stored procedures in the future, I am going to have to re-visit my VB code too and alter the parameter settings here as well.

View 4 Replies

ADO.NET :: Pass Input Parameters To SP And Fetch Output Parameter?

Jan 18, 2011

i like to pass two i/p parameters to the SP and fetch 2 output parameters.This should done using simple ADO .NET code.

View 1 Replies

SQL Server :: Searching Table With Multiple Parameters?

Sep 16, 2010

I want to query an SQL table using some Web controls to provide the parameters for filtering the records in the table. Results are displayed in a GridView.

I have a TextBox with an ID of "keyword" where the user may enter one or more keywords. I'd like to search 2 columns for instances of these keywords.

I also have a DropDownList named "category" that lists categories contained in a "category" column of the table.

I have a dataset with a TableAdapter for the table I want to search. Got it working fine with the DropDown List but not sure how to proceed with the TextBox and keywords.

What SQL query should I use? The user may not enter anything into the textbox, they may enter one word, or multiple words.

This is where I am now:

SELECT * FROM tablename WHERE category = @category AND ??

View 7 Replies

ADO.NET :: Stored Proc With Output Parameters / Data In The Output Parameters From The Stored Procedure?

Mar 30, 2011

I have a stored procedure that works fine for classic asp, but how can I get my output parameters data back from in /MVC 2 / linq/ entities framework model . I have inported the function also, but when i try to code it i dont get results ...i know this is a matter of lack of / knowledge or exmple because i have been scouring the web for it and cannnot find into that accually works.

here is the stored proc.

[Code]....

Here was the one of the few tries I did:

[Code]....

but it executes fine does not give me an error, but also does not return the info i need to the viewmodel

I keep seeing stuff about "ref" on the net but "ref" shows " arbument # should not be passed with the ref keyword.

So i am not sure if there is a problem with the model, or with my understanding this, Now for your info I can do the same step with returning a dataset from a stored procedure fine, but I dont want a data set I just want excatly the data in the output parameters from the stored procedure.

View 2 Replies

How To Get Output Parameters From SQL Server Using ASP

Oct 8, 2010

I had an sqldatasource. I had set its parameter as follows

[Code]....

View 10 Replies

SQL Server :: Stored Procedures Output Parameters?

Mar 16, 2011

I have never used stored proc ouput parameters i want to know what is the use of using output parameters?If possible provide me some code.

View 10 Replies

SQL Server :: Retrieving Two Output Parameters In A Stored Proc Called From C#?

Mar 29, 2011

I've modified an existing strored procedure. It originally had one ouput parameter in the stored proc and it was set up as follows in the c# code that called it:

cmd.Parameters.Add("@Var1Param", SqlDbType.BigInt);
if (Var1 == 0)
cmd.Parameters["@Var1"].Value = DBNull.Value;
else
cmd.Parameters["@Var"].Value = Var1;
cmd.Parameters["@Var1"].Direction = ParameterDirection.InputOutput;
cmd.ExecuteNonQuery();
// Get Var1
Var1= dataMorph.ToInt64(cmd.Parameters["@Var1"].Value.ToString());

Just to clarify, this parameter was declared as OUTPUT in the stored proc but as inputoutput in the C# code. This worked fine. I have added another parameter to the same stored procedure and I want to retrieve both from the C# code. The C# code now is as follows:.................................

View 3 Replies

SQL Server :: Select Disticnt With 2 Parameters?

Mar 17, 2011

if i write:-SELECT Distinct TOP(10) Data,parentcategoryid.then it does not give me distinct.it gives me repeated values.i dont now what to do.but,if i write SELECT Distinct TOP(10) Data then it gives me disticnt valeus. what is the prob. and how to solve?

View 5 Replies

SQL Server :: Passing Parameters For Select Query To Another Page

Dec 14, 2010

I have an asp.net site which includes a "search" page that queries an SQL table, then redirects the user to a "results" page where the results of the query are displayed. The parameters for the query are assembled into a string which is the SELECT statement. I've been asked to add additional functionality that requires a secondary search which takes place on the "results" page. How can I pass the parameters from the "search" page to the "results" page so that I can access those parameters in the code behind? Here's the first page code behind (I inherited most of this from another developer):

[Code]....

And the second page--it would be on line 51 that I would need to insert the parameters from the search above:

[Code]....

View 3 Replies

SQL Server :: Stored Procedure With Multiple Parameters?

Nov 28, 2010

I have a table with 4 columns.The first column is a list of teams.The other three columns specify whether the team member with the particular id is present on any particular day .Say for example in the third row the running Team has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.I have a Query like this

Select Teamname from tblTeam where Running not like '%|2|%' and Running not like '%|3|%' and Running not like '%|7|%' and Biking not like '%|1|%' and Biking not like '%|4|%' and Biking not like '%|7|%' and shooting not like '%|3|%' and shooting not like '%|4|%' and shooting not like '%|7|%' Basically i am searching the columns with like clause.The search criteria for each column may vary.In the above query i am searching for Teams where Running column does not contain 2,3 and 7,Biking column does not contain 1,4 and 7 and the shooting column does not contain 3,4 and 7. I would like to set a stored procedure where i would be able to pass 3 set of parameters from the code behind(I am using VB.net) for Running column search,Biking column search and the shooting column search.

Can someone tell me writing a simple stored procedure.I have a table with 4 columns.The first column is list of teams.The other three columns specify whether the team member with the particular id is present or not on any particular day .Say for example in the third row the running column has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.

View 13 Replies

Web Forms :: Cannot Display Output Parameters

Jan 22, 2010

I have a webform which inserts data into a sql table successfully (form is bound to SqlDataSource1). The problem I have is that I need to populate a number of the DataFields based on an entered Ref number from a button click. The Ref is passed into a Stored Procedure as the only input parameter, all other params are output params. The procedure seems to run fine, but I can not seem to display any of the output params in my form. Here is my sproc:

PROC AUMS_RETURN_LOOKUP
(
@REF
@COMPANY
@SALUTATION
@FORENAME
@SURNAME
@ADDRESS1
@ADDRESS2
@ADDRESS3
@ADDRESS4
@ADDRESS5
@ADDRESS6
@CITY
@COUNTRY
@POSTCODE
BIGINT,
char(10)
OUTPUT,
char(20)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(50)
OUTPUT,
char(30)
OUTPUT,
char(30)
OUTPUT,
char(20)
OUTPUT
)
AS
SET
NOCOUNT ON
SELECT
@SALUTATION
@FORENAME
@SURNAME
@ADDRESS1
@COMPANY =
rtrim([COMPANY]),
=
RTRIM([SALUTATION]),
=
RTRIM([FORENAME]),
=
RTRIM([SURNAME]),
=
RTRIM([ADDRESS1]),
@ADDRESS2 =
RTRIM([ADDRESS2]),
@ADDRESS3 =
RTRIM([ADDRESS3]),
@ADDRESS4 =
RTRIM([ADDRESS4]),
@ADDRESS5 =
RTRIM([ADDRESS5]),
@ADDRESS6 =
RTRIM([ADDRESS6]),
@CITY =
RTRIM([CITY]),
@COUNTRY =
RTRIM[COUNTRY]), @POSTCODE
=
RTRIM([ZIP])
FROM
HEADER
WHERE
REF = REF
Here is my code:
Protected
Sub Button1_Click1(ByVal sender
As
Object,
ByVal e
As System.EventArgs)
Dim Company
As TextBox =
DirectCast(FormView1.FindControl("TextBox9"), TextBox)
Dim Forename
As TextBox =
DirectCast(FormView1.FindControl("TextBox10"), TextBox)
Dim Surname
As TextBox =
DirectCast(FormView1.FindControl("TextBox8"), TextBox)
Dim TESTREFTextBox
As TextBox =
DirectCast(FormView1.FindControl("TxtBox_ref"), TextBox)
Dim TESTREF = Convert.ToInt64(TESTREFTextBox.Text)
Dim CompanyText = Company.Text
Dim strCon
As
String = ConfigurationManager.ConnectionStrings("ConnString").ConnectionString
Dim Con
As
New SqlConnection(strCon)
Dim Cmd
As SqlCommand
Con.Open()
Cmd = New SqlCommand
Cmd.CommandText = "RETURN_LOOKUP"
Cmd.CommandType = CommandType.StoredProcedure
Cmd.Parameters.Add("@REF", SqlDbType.Int)
Cmd.Parameters("@REF").Value = TESTREF
Cmd.Parameters.Add("@COMPANY", SqlDbType.VarChar, 15)
Cmd.Parameters("@COMPANY").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@SALUTATION", SqlDbType.VarChar, 20)
Cmd.Parameters("@SALUTATION").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@FORENAME", SqlDbType.VarChar, 50)
Cmd.Parameters("@FORENAME").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@SURNAME", SqlDbType.VarChar, 50)
Cmd.Parameters("@SURNAME").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS1", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS1").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS2", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS2").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS3", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS3").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS4", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS4").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS5", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS5").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@ADDRESS6", SqlDbType.VarChar, 50)
Cmd.Parameters("@ADDRESS6").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@CITY", SqlDbType.VarChar, 30)
Cmd.Parameters("@CITY").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@COUNTRY", SqlDbType.VarChar, 30)
Cmd.Parameters("@COUNTRY").Direction = ParameterDirection.Output
Cmd.Parameters.Add("@POSTCODE", SqlDbType.VarChar, 20)
Cmd.Parameters("@POSTCODE").Direction = ParameterDirection.Output
Cmd.Connection = Con
"@REF", SqlDbType.Int)"@REF").Value = REF"@COMPANY",
SqlDbType.VarChar, 15)"@COMPANY").Direction = ParameterDirection.Output"@SALUTATION",
SqlDbType.VarChar, 20)"@SALUTATION").Direction = ParameterDirection.Output"@FORENAME",
SqlDbType.VarChar, 50)"@FORENAME").Direction = ParameterDirection.Output"@SURNAME",
SqlDbType.VarChar, 50)"@SURNAME").Direction = ParameterDirection.Output"@ADDRESS1",
SqlDbType.VarChar, 50)"@ADDRESS1").Direction = ParameterDirection.Output"@ADDRESS2",
SqlDbType.VarChar, 50)"@ADDRESS2").Direction = ParameterDirection.Output"@ADDRESS3",
SqlDbType.VarChar, 50)"@ADDRESS3").Direction = ParameterDirection.Output"@ADDRESS4",
SqlDbType.VarChar, 50)"@ADDRESS4").Direction = ParameterDirection.Output"@ADDRESS5",
SqlDbType.VarChar, 50)"@ADDRESS5").Direction = ParameterDirection.Output"@ADDRESS6",
SqlDbType.VarChar, 50)"@ADDRESS6").Direction = ParameterDirection.Output"@CITY",
SqlDbType.VarChar, 30)"@CITY").Direction = ParameterDirection.Output"@COUNTRY",
SqlDbType.VarChar, 30)"@COUNTRY").Direction = ParameterDirection.Output"@POSTCODE",
SqlDbType.VarChar, 20)"@POSTCODE").Direction = ParameterDirection.OutputDim
result As
String
Cmd.ExecuteNonQuery()
result = Cmd.Parameters("@COMPANY").Value
CompanyText = result

View 4 Replies

Cannot Retrieve Output Parameters Until SqlDataReader Is Closed

Apr 13, 2010

While the SqlDataReader is being used, the associated SqlConnection is busy serving the SqlDataReader, and no other operations can be performed on the SqlConnection other than closing it. This is the case until the Close method of the SqlDataReader is called. For example, you cannot retrieve output parameters until after you call Close.

If the above claim is true, then why is the following method able to retrieve a value from output parameter before the reader is closed:

public int Something()
{
using (SqlConnection con = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("some_procedure", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ID", SqlDbType.Int).Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteReader();
return (int)cmd.Parameters["@ID"].Value;
}
}

You can reset the CommandText property and reuse the SqlCommand object. However, you must close the SqlDataReader before you can execute a new or previous command.

Why must you close sqldatareader before you execute new command?

View 2 Replies

ADO.NET :: How To Define Date Output Parameters For A Stored Procedure

Oct 15, 2010

I have a question. How do we define date output parameters for a stored procedure?

before you answer,I should mention that I am not referring to the sql syntax definition ,which is @mydate datetime output.

This is ok,what i am asking is HOW DO I SPECIFY IT IN LINQ WHEN I NEED TO CALL THE STORED PROCEDURE IN THE SERVER SIDE CODE. I am repeating that I do I am not referring to the sql definition .

View 1 Replies

DataSource Controls :: Programmatically Setting ODS Select Method And Select Parameters?

Dec 22, 2010

The drop down list is used to determine what search criteria will be used to find an invoice. I tried to set the Select method in the switch statement. I don't understand how to set the Select Method and the select parameters programmatically though . I tried a few different ways but can't make the compiler happy. My ODS is in scope in the code behind. I'm not able to access it's properties though. The BAL resides in a separate project that is a ClassLibrary. I also have a using statement for the ClassLibrary project in the code behind.

give me an example of how to do this?

Mark up:

[Code]....

[Code]....

[Code]....

[Code]....

View 1 Replies

ADO.NET :: How To Call A Stored Procedures With Varchar Output Parameters In LINQ

Oct 15, 2010

I have a stored procedure with the following structure:

[Code]....

View 4 Replies

DataSource Controls :: Deprecated Types Not Supported As Output Parameters

Jan 21, 2010

i am trying to do: Parameters.Add("@ProfileHtml", SqlDbType.Text, MAX_TEXT).Direction = ParameterDirection.Output but i keep getting this error. MAX_TEXT is integer = 2147483647 Data type 0x23 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object types instead.

View 4 Replies

Php - Validate If An Web Application Gets The Users Input Or Parameters?

Oct 21, 2010

I am always thinking about validation in any kind on the webpage (PHP or ASP, it doesn't matter), but never find a good and accurate answer. For example, a I have some GET-Parameter, which defines a SQL query like DESC oder ASC. (SQL-Injection?) Or I have a comment-function for user, where the data is also saved in a database.

Is it enought to check for HTML-tags inside the data? Should the validation done before adding it to the database or showing it on the page? I am searching for the ToDo's which should be always performed with any data given from "outside".

View 3 Replies

How To Define A Route That Have 2 Optional Parameters In The Middle Of The URL The Start An End Parameters Are Digits

Jun 7, 2010

I want to define a route that have 2 optional parameters in the middle of the URL the start an end parameters are digits

[Code].....

View 1 Replies

Forms Data Controls :: How Specify Input Parameters To UpdateCommand

Oct 9, 2010

How specify input parameters to UpdateCommand

View 3 Replies

WCF / ASMX :: Webservice Custom Objects As Input Parameters?

Nov 9, 2010

I have a fundamental question to ask about web services. I'm currently writing a service that has custom classes (lots of them). Let's say a car is one example. For some reason I was thinking that the service should expose these objects. However once I created a site to consume the service, it looks as though the classes are not meant to be exposed. It looks like the best practice is to take in a string which may be xml or not and convert that string into the object in the service code.(especially for error handling or input validation)

For example, if I had the web method:

[WebMethod]
public car getCar(int carId)
{
//code here to return car object
}

This will take a car ID and return a car object. It also shows all the elements in the SOAP request and response objects (as well as the WSDL) which can be to external developers. However, when trying to consume the service from a website (or reference it in my code), I then need access to the Car class (which implies i need to expose it through the services as well?).

View 5 Replies

MVC :: MVC3 RC2 Bug Binding From Request Parameters To Method Parameters?

Dec 10, 2010

Since ASP.NET MVC3 RC2 I encounter a bug when posting values to a controller method of which one of the parameter is a nullable int. Steps to reproduce:

I've created a test method

[code]....

In MVC3 RC1 this was working without any problems with the nullable int

Update:
I don't seem to have the problem with a newly created MVC3 website. What could I have in my project that influence model binding to nullable int's? And why would there be a difference between RC1 and RC2?

View 10 Replies

How To Get The Individual Parameters From The List Of Dynamic Parameters In A Webmethod

May 12, 2010

I am using jquery ajax method on my aspx page,which will invoke the webmethod in the code behind.Currently the webmethod takes a couple of parameters like firstname,lastname,address etc which I am passing from jquery ajax method using

data:JSON.stringify({fname:firstname,lname:lastname,city:city})

now my requirement has been changed such that,the number and type of parameters that are going to be passed is not fixed for ex.parameter combination can be something like fname,city or fname,city or city,lname or fname,lname,city or something else.So the webmethod should be such that it should accept any number parameters.I thought of using arrays to do so, as described here.

But I do not understand how can I identify which and how many parameters have been passedto the webmethod to insert/update the data to the DB.

View 4 Replies

DataSource Controls :: Objectdatasource With Unpredictable Number Of Input Parameters?

Dec 10, 2010

I'm trying to use an objectdatasource and populate it with a query that has "or" in its where statement. eg: select * from customers where customer_id = "34" or "35" or "36"The problem is... I don't know ahead of time how many of these "or" conditions there will be - the user can choose as many or as few as they want. It seems that if I want to use an objectdatasource tied to a tableadpater I'm forced to know the number of parameters ahead of time so that I can build the objectdatasource's input parameters e.inputparameters.add doesn't work, because the key (in this case "id") is the same for each parameter because the where statment has "or"s....

View 7 Replies

C# - Dynamic Return Type Based On The Input - Create A Function Which Would Have Two Parameters

Feb 14, 2011

I want to create a function which would have two parameters

public **XYZ** GetOputput(string strToConvert, **ABC**)

What I want from this function, that I will send a string to this function and the datatype in which I want to convert this string [Ex: Int32,Int64, datetime etc..] and the return will be the same as the datatype I have sent as the input parameter.

I want to have something like this in my function:

[code]....

View 5 Replies







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