Sql编码说明 [英] Sql Coding Explanation

查看:76
本文介绍了Sql编码说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

逐行解释下面附带的代码:



Explain below attached code line by line:

public void BindData() 
{ 
SqlCommand cmd; 
cmd = new SqlCommand("sp_GetEmployeeDetails", con); 
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.Add(new SqlParameter("@roll", SqlDbType.VarChar)).Value = DropDownList1.SelectedValue; 
cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)).Value = TextBox1.Text; 

con.Open(); 
SqlDataAdapter da = new SqlDataAdapter(cmd); 

DataTable dt = new DataTable("Table"); 
da.Fill(dt); 
con.Close(); 
GridView1.DataSource = dt; 
GridView1.DataBind(); 

}

推荐答案

我会简单地告诉你



您正在SQL Server上执行存储过程,方法是传入2个参数并在DataGridView中显示结果。



如果你想要要逐行了解我会建议您使用谷歌每个命令,你想了解更多。为什么?正如你将学到更多的东西!



这是你的第一个

SqlCommand [ ^ ]
I''ll tell you in a nutshell

you are executing a stored procedure on the SQL Server by passing in 2 parameters and displaying the results in a DataGridView.

If you want to know it line by line I would suggest that you either Google each command that you want to know more about. Why? As you will learn more that way!

Here is the first one for you
SqlCommand[^]


这篇关于Sql编码说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆