做了个登陆界面,通过调用储存过程,顺利完成了
string afile = "server = 127.0.0.1; uid =joerson; pwd = 123; database =students";
SqlConnection connnection = new SqlConnection(afile);
SqlCommand acmd = new SqlCommand("login", connnection);
acmd.CommandType = CommandType.StoredProcedure;
/* login= CREATE PROCEDURE login (@uid char(20),@pwd char(20)) AS select uid ,pwd
from admin where uid=@uid and pwd =@pwd
GO */
//如果要进行权限分配判断,是不是应该如下:添加另一个数据库操作呢
// SqlCommand acmd = new SqlCommand("stulogin", connnection);
// acmd.CommandType = CommandType.StoredProcedure;stulogin= CREATE PROCEDURE stulogin (@uid char(20),@pwd char(20)) AS select stu_id ,pwd
from student where stu_id=@uid and pwd =@pwd
GO
SqlParameter uid = new SqlParameter("@uid", SqlDbType.Char, 20);
uid.Value = textBox1.Text;
acmd.Parameters.Add(uid);
SqlParameter pwd = new SqlParameter("@pwd", SqlDbType.Char, 20);
pwd.Value = textBox2.Text;
acmd.Parameters.Add(pwd);
connnection.Open();
acmd.ExecuteNonQuery();
SqlDataReader dr = acmd.ExecuteReader();
if (dr.Read())
{
this.Close();
this.Dispose();
Form2 f2 = new Form2();
f2.ShowDialog();
}
else
{
MessageBox.Show("用户名或密码错误");
}
但是,从这个登陆界面,又引申出一个问题:如何在程序中进行权限的分配呢
因为本人是自学的,可参考资料不多,网上搜索到的都是数据库的权限分配,可能是小菜太笨了,都看不懂
所以想请问下各位达人,如何在程序中判断并分配权限呢?....
[此贴子已经被作者于2006-12-4 13:56:03编辑过]