Login code to connect the database with asp.net

Source: Internet
Author: User
Connect the database with the ASP.net, do the login page, how to get it.
Way:
Using system.data.sqlclient;//Remember to add a reference to
private bool Login (string sno,string sname)
{
SqlConnection con = new SqlConnection ("Data source= database connection; Initial catalog=stu_table; User Id=sa; password=123456789 ");
Con. Open ();
String sql = string. Format ("SELECT count (*) from Student where sno= ' {0} ' and Sname= ' {1} '", sno,sname);//Here you change yourself, do not know what you use login, account password do not know what field you use, For the time being, you use your number and name to login
SqlCommand com = new SqlCommand (sql, con);
int flag = (int) com. ExecuteScalar ();
Con. Close ();
if (Flag > 0)
{return
true;
}
return false;
}


Put the above code in the Login.aspx.cs inside, where you log on to call this function, pass the login account and password come in on the line.
Returns True if the login is successful, otherwise it returns false
Landing success you can jump to your page with the following statement
Response.Redirect ("Inside You jump URL");
Landing failure You can hint
Response.Write ("<script> alert (' Account password error ');</script>");
The logic of the above can not write, then there is no way, the children will be
Database connection: This you change, general use. Say, you can also open your own database to see.




Question: How to implement the mouse following event and the binding of the scroll bar.
Mouse following events in the body height, want to follow the picture to a certain position after not change, is why.
The code is as follows:
<!
DOCTYPE html>  


Reply:
Look here: Var x=e.pagex,y=e.pagey;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.