如何使用存储过程在C#Asp.Net中开始编码 [英] How Can I Start To Code In C# Asp.Net By Using Stored Procedure
本文介绍了如何使用存储过程在C#Asp.Net中开始编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人建议我如何学习如何在c#asp.net中成为一名优秀的程序员吗?
Is anyone suggest me to how i can learn n perform to be a good programmer in c# asp.net???
推荐答案
你没有代码在C#中使用存储过程 - 存储过程是SQL服务器的一部分,允许您保存常用的SQL命令,这样您就可以非常简单地从C#代码中执行它们。
这样做很容易。如果您有SP:
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:
CREATE PROC [dbo].Sample
@Name varchar(100) OUTPUT
AS
BEGIN
SELECT @Name=Username FROM myTable WHERE iD=1
END
然后从中使用它C#:
Then to use it from 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);
我会向你推荐你可以学习的最好的链接你将能够开始编码
从使用存储过程插入单值开始ASP.NET C#
http://www.c-sharpcorner.com/UploadFile / ca2535 / insert-update-and-delete-using-stored-procedure-in-sql-ser / [ ^ ]
来自此链接,您将逐步学习
,这是另一个非常真实的来源 MVA 。有你想要的一切
http:/ /www.microsoftvirtualacademy.com/product-training/sql-server [ ^ ]
如果您满意,请告诉我
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
这篇关于如何使用存储过程在C#Asp.Net中开始编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文