Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Is anyone suggest me to how i can learn n perform to be a good programmer in c# asp.net???
Posted
Comments
Richard MacCutchan 14-Oct-15 6:47am    
Practice, practice, practice.

You don't "code in C#" with stored procedures - stored procedures are a part of SQL server and allow you to save commonly used SQL commands so you can execute them very simply from your C# code.

To do that is easy. If you have an SP:
SQL
CREATE PROC [dbo].Sample
@Name varchar(100) OUTPUT
AS
BEGIN
SELECT @Name=Username FROM myTable WHERE iD=1
END
Then to use it from C#:
C#
string r;
string s;
using (SqlConnection con = new SqlConnection(@"Data Source=GRIFFPC\SQLEXPRESS;Initial Catalog=myDatabase;Integrated Security=True"))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("Sample", con))
        {
        com.CommandType = CommandType.StoredProcedure;
        SqlParameter name = new SqlParameter("@Name", SqlDbType.VarChar, 100);
        name.Direction = ParameterDirection.Output;
        com.Parameters.Add(name);
        com.ExecuteNonQuery();
        r = (string) name.Value;
        s = (string) com.Parameters["@Name"].Value;
        }
    }
Console.WriteLine("Name : {0}\nParam: {1}", r, s);
 
Share this answer
 
i am gonna recommend you the best links you can learn from, after studying them you'll be able to start codding

Start from Inserting Single Value With Stored Procedure ASP.NET C#
http://www.c-sharpcorner.com/UploadFile/ca2535/insert-update-and-delete-using-stored-procedure-in-sql-ser/[^]

from this link you gonna learn step by step
and here is another very authentic source MVA. there is everything you are looking for

http://www.microsoftvirtualacademy.com/product-training/sql-server[^]

and please let me know if you get satisfied
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900