在sql数据库中写一个存储过程,在c#中程序中调用这个存储过程。
userLoginConnection.Open();SqlCommand checkUserCommand = new SqlCommand("checkUserProcedure" , userLoginConnection);checkUserCommand.CommandType = CommandType.StoredProcedure;SqlParameter paramUserName = new SqlParameter("@userName" , SqlDbType.VarChar , 20);
paramUserName.Value = txtUserName.Text;
checkUserCommand.Parameters.Add(paramUserName);SqlParameter paramPassword = new SqlParameter("@password" , SqlDbType.VarChar , 20);
paramPassword.Direction = ParameterDirection.Output;
checkUserCommand.Parameters.Add(paramPassword);checkUserCommand.ExecuteNonQuery();password = (string)checkUserCommand.Parameters["@password"].Value;
userLoginConnection.Open();SqlCommand checkUserCommand = new SqlCommand("checkUserProcedure" , userLoginConnection);checkUserCommand.CommandType = CommandType.StoredProcedure;SqlParameter paramUserName = new SqlParameter("@userName" , SqlDbType.VarChar , 20);
paramUserName.Value = txtUserName.Text;
checkUserCommand.Parameters.Add(paramUserName);SqlParameter paramPassword = new SqlParameter("@password" , SqlDbType.VarChar , 20);
paramPassword.Direction = ParameterDirection.Output;
checkUserCommand.Parameters.Add(paramPassword);checkUserCommand.ExecuteNonQuery();password = (string)checkUserCommand.Parameters["@password"].Value;
解决方案 »
- .NET远程对象访问的问题
- 哪位大神可以给我解释下接口的意义
- <asp:HyperLink>问题
- 一个数据库备份的问题??????急呀。。。。。
- 如何动态设置BackColor
- 在线等待,马上结贴,各位大哥求教啊,Windows程序里面我想双击treeView的一个节点,弹出一个窗口,并且只有双击子节点才弹出来,最顶的父节点
- 继承CollectionBase的类绑DataGrid,怎样实现增加删除?
- 我的存贮过程应该怎么写啊
- 我们用C#开发的ERP studio,准备把项目的源代码共享
- VS2012里面的Reporting是什么项目呢
- 目前程序开发人员的收入调查
- 打算买本书学C#,不知这本书如何?
SqlConnection con=new SqlConnection("你的连接字串");
SqlCommand cmd=new SqlCommand(sql,con);
con.Open();
SqlDataReader dr=cmd.ExecuteReader();
DataGrid1.DataSource=dr;
DataGrid1.DataBind();
dr.Close();
con.Close();
public class DataCenter()
{
private SqlConnection conn;
public DataCenter()
{
conn = new SqlConnection("连接字符串");
}
public void SqlQuery(int Query)
{
this.conn.Open();
string sql = "SELECT * FROM A WHERE a < " + Query;
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNoQuery();
this.conn.Close();
}
}
{
SqlConnection connection = new SqlConnection( ".... "//Connection String );
SqlDataAdaper dscommand = new SqlDataAdaper();
DataSet dataSet = new DataSet();
connection.Open();
dscommand.SelectCommand = new SqlCommand( "Select * from table where a <=" + aValue, connection );
dscommand.Fill( dataSet );
connection.Close();
return dataSet;
}***********************************************
this.dataGrid.DataSourece = this.dataSet.Tables[0].DefaultView;