473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

sample code

Hi there - I need some help. I need to find some csharp sample code that
uses a stored procedure to return a single value.Any help is appreciated.

thanks
Casey
Nov 16 '05 #1
4 1536
You didn't stretch too much to describe the problem in more details, did
you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Casey" <CL*****@synoptics.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi there - I need some help. I need to find some csharp sample code that
uses a stored procedure to return a single value.Any help is appreciated.

thanks
Casey

Nov 16 '05 #2
Or to try to find the answer to the problem on your own for that matter?

At any rate, I don't know for sure if the MSDN docs contain code samples on this specific subject, but you if you look up the SqlCommand and SqlParameter classes from the System.Data.SqlClient namespace, that should get you started.

"Miha Markic [MVP C#]" wrote:
You didn't stretch too much to describe the problem in more details, did
you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Casey" <CL*****@synoptics.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi there - I need some help. I need to find some csharp sample code that
uses a stored procedure to return a single value.Any help is appreciated.

thanks
Casey


Nov 16 '05 #3
Unlike others who critize I look to help.

Casey, the following code executes a stored procedure on sql server and
returns a single value. Let me know if you need anything else:

SqlConnection conn = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand("UserRole", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.Parameters.Add(new
SqlParameter("@value",SqlDbType.NVarChar,10,Parame terDirection.ReturnValue,
false,0,0,"Value",DataRowVersion.Default, null));
cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;
cmd.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value =
UserName.Text;
cmd.Parameters.Add("@password", SqlDbType.NVarChar, 20).Value =
Password.Text;
cmd.ExecuteNonQuery();
string value = cmd.Parameters["@value"].Value.ToString();
if (value == "1")
Label1.Text = "Admin";
if (value=="2")
Label1.Text = "User";
if (value=="3")
Label1.Text = "public";
conn.Close();

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Or to try to find the answer to the problem on your own for that matter?

At any rate, I don't know for sure if the MSDN docs contain code samples on this specific subject, but you if you look up the SqlCommand and
SqlParameter classes from the System.Data.SqlClient namespace, that should
get you started.
"Miha Markic [MVP C#]" wrote:
You didn't stretch too much to describe the problem in more details, did
you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Casey" <CL*****@synoptics.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi there - I need some help. I need to find some csharp sample code that uses a stored procedure to return a single value.Any help is appreciated.
thanks
Casey


Nov 16 '05 #4
Hi Neil,

Are you sure he is using Sql server?
What kind of return value does his stored procedure return?
etc.
Not that we don't want to help but a little bit more details would come
handy....

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Neil" <Neil.Carnavan(@)cgh.bc.ca> wrote in message
news:Og**************@TK2MSFTNGP12.phx.gbl...
Unlike others who critize I look to help.

Casey, the following code executes a stored procedure on sql server and
returns a single value. Let me know if you need anything else:

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John MacIntyre | last post by:
Hi, Can anybody give me a hint as to how to convert a javascript array into a vbscript array? BTW-it only needs to work in IE5 & 6 Thanks in advance, John MacIntyre VC++ / VB / ASP /...
15
by: Alex Vinokur | last post by:
I am looking for any custom allocator sample code for std::vector. Thanks. -- Alex Vinokur http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn
1
by: Curious | last post by:
Hi List, Obviously my google-fu is very weak and I can't find a simple sample code for C++ that allows me to simply download the source of a specified web page. I'm looking at downloading the...
2
by: Sivana | last post by:
Hey, Does anyone have any sample code where I can transfer list items between two list boxes. C# and WinForms. Thanks
1
by: Peri | last post by:
Dear All, Can you one give me some sample code for connecting to the SQL server DB and executing a stored procedure in the SQL server using ASP.NET ? I also need to display the result set in...
30
by: Chad Z. Hower aka Kudzu | last post by:
I need to provide a series of demos for an assembly. There are potentialy several dozen of them. None of them are very complex, however maintaining two versions of them will be very maintainance...
3
by: Nikolay Petrov | last post by:
I've found some sample code in MSDN, which is interesting to me. There are two problems about it. It is in C# and second it think somethig is wrong with it. The some namespaces used in it does not...
1
by: Ian | last post by:
I've just discovered the msclr::lock class in the C++ Support Library online documentation. This seems like a much cleaner way to implement thread protection than using...
5
by: Will | last post by:
- I know enough ASP and Access to be dangerous :) - I need to put up a data base on our web server with 3 related tables. - They will be accessed by a limited number of people. - Each user will...
0
by: Andrus | last post by:
MSDN Winforms DataGridView VirtualMode with caching sample code DataRetriever loads two pages always to cache thus making 2 database accesses. If datagridview uses one page of data, second page...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.