有关数据库插入和检索的C#代码 [英] C# code on database insertion and retrieval

查看:78
本文介绍了有关数据库插入和检索的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为带有会话的密码和用户名创建数据库,以区分普通用户和管理员.

how do i create database for the passwords and user names with sessions to distinguish between the ordinary user and the administrator.

推荐答案

在用户"表名中添加一列角色并为每种类型的用户分配不同的角色,例如,对于普通用户,管理员1的角色2

然后在登录时检查role的值,如果为1,则进行admin会话并重定向到admin部分

否则重定向到普通用户
Make a column in User table name Role and assign each type of user a different role for eg 1 for admin 2 for normal user

then at the time of login check for the value of role,if it is 1 then make admin session and redirect to admin section

otherwise redirect to normal user


在数据库中创建2个用户名密码.
Windows形式的两个标签n 2 textbocxes..
按钮插入
双击按钮...
相同的插入代码..

按钮单击
{
cmd = new SqlCommand(插入ShiftMaster值(""+ cboxGroupName.Text +",""+ txtShiftCode.Text +"'',con);//两个文本框她...
con.open();
cmd.executeNonQuery();
con.close();
Messagebox.show(插入");
}
create 2 coloumns Username Password in DB.
Two labels n 2 textbocxes in Windows form..
Button insert
double click on button...
same insertion code..

button click
{
cmd = new SqlCommand("insert into ShiftMaster values(''" + cboxGroupName.Text + "'',''" + txtShiftCode.Text + "'', con);//two textboxes her...
con.open();
cmd.executeNonQuery();
con.close();
Messagebox.show("Inserted");
}


亲爱的同学,

如果您提供有关正在从事哪种技术和项目的完整信息,那总会更好.就像如果您使用Asp .Net,也可以使用asp.net角色管理.
看看.

http://msdn.microsoft.com/en-us/library/ff647401.aspx [ ^ ]

祝你好运!
Dear fellow,

It is always better if you provide full information that which technology and project you are working on. Like If you are using Asp .Net, you can also use asp.net role management as well.
Take a look.

http://msdn.microsoft.com/en-us/library/ff647401.aspx[^]

Good Luck!


这篇关于有关数据库插入和检索的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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