如何使用MySQL数据库在Visual C#中创建登录表单 [英] How to create a login form in visual c# using mysql database

查看:71
本文介绍了如何使用MySQL数据库在Visual C#中创建登录表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Visual C#中创建一个登录表单,但是我面临着如何检查用户输入的用户名和密码是否与mysql表中的USERNAME和PASSWORD匹配的问题.我希望用户在文本框中输入用户名和密码,然后程序将搜索表格,以及是否找到用户名和密码.程序将显示主窗体,如果不显示错误消息.

请帮助我如何完成此任务(我是C#的初学者),或者如果我在哪里可以找到C#编程和mysql中作为数据库的引用或资源,请提供帮助.

谢谢.

I am currently creating a login form in visual c#, but i am facing problem on how to check if the user input username and password match with the USERNAME and PASSWORD in mysql table. I want the user to input a username and password in the text box then the program will search the table and if the username and password found. the program will display the main form, if not display error message.

Please help on how to accomplish this task i am beginner in c# or please help if where can i find a references or resources in c# programming and mysql as database.

Thanks.

推荐答案

http://www.c-sharpcorner.com/Forums/Thread/84214/ [ ^ ]
http://social.msdn.microsoft.com/Forums/sk/csharpgeneral/thread/8b714ff6-acbf-43bf-9ab8-d61921549c36[^]
http://www.c-sharpcorner.com/Forums/Thread/84214/[^]


HI这将帮助您复制并粘贴



HI This will help you copy and paste it



SqlConnection con = new SqlConnection("Connection");
            SqlCommand cmd = new SqlCommand("select pwd,userName from LoginTable",con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(da);
            if (txtPassword.Text == dt.Rows[0]["pwd"].ToString() && txtUserName.Text == dt.Rows[0]["userName"].ToString())
            {
                Response.Redirect("abc.aspx");
            }
            else
            { 
            //Error display Msg
            }


这篇关于如何使用MySQL数据库在Visual C#中创建登录表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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