登录时如何从数据库中检索数据 [英] how to retrive data from database when login

查看:84
本文介绍了登录时如何从数据库中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在表格中创建了aspx页面

I have create aspx page like that inside the table

<tr>
                <td>
                    <asp:Label ID="lblusername" runat="server" Text="Username"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtusername" MaxLength="20" runat="server"></asp:TextBox>
                </td>
                         
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblpassword" runat="server" Text="Password"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtpassword" MaxLength="30" TextMode="Password" runat="server"></asp:TextBox>
                </td>
            </tr>



那么在default.aspx.cs中,使用存储过程的代码是什么



then in default.aspx.cs what is the code by using stored procedure

protected void btnsignIn_Click(object sender, EventArgs e)
    {
         what will the code to compare username and password using stored procedure
    }

推荐答案

在存储过程中,传递用户名和密码,然后进行选择查询,例如

In stored procedure pass username and password then make select query like

Select * from table where username=@uname and password=@pwd



用于以编程方式执行查询 [



for executing the query programatically Check this[^]


只需将参数作为用户名和密码传递给存储过程..

然后进行这样的存储过程...

Just pass parameter as your user name and password to your store procedure..

and make store procedure like this...

select * from "tablename" where username = @usernam and password = @password



如果此查询返回内容或返回任何行,则您的用户将有效,否则无效...

使用您的代码调用该过程,并分别传递您的文本框值,然后查看该过程的结果以进行验证



if this query return something or return any row then your user will valid else not valid...

call that procedure using your code and pass your text boxes value respectively and see the result of your procedure for validation


这篇关于登录时如何从数据库中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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