首页 > 编程知识 正文

c代表什么,c是什么意思

时间:2023-05-06 01:30:30 阅读:18623 作者:4505

自动售货机

:聂宝根

实现登录界面

实现后台代码//获取用户输入信息string uname=txt userid.text.trim (; stringupwd=txt userpwd.text.trim (; //确定是否为空,设置值为空或空的字符串if(string.isnullorempty(uname ) )//提示框的标题和提示信息,然后单击消息提示框中的图标messagebox 请再输入一次!' 、“登录提示”、MessageBoxButtons.OK和MessageBoxIcon.Error; txtUserId.Focus (; //对焦返回; }if(string.isnullorempty(upwd ) { MessageBox.Show ) )密码为空。 请再次输入! '、“登录提示”、MessageBoxButtons.OK和MessageBoxIcon.Error; txtUserPwd.Focus (; 返回; //建立与数据库通信并检查输入是否与数据库匹配的//与数据库的连接//连接字符串,- -密钥string connstring=' data source=localhost; 数据库=student db; 用户id=root; password=admin; charset=utf8 '; mysqlconnectionconn=newmysqlconnection (connstring ); //写入查询语句string SQL=' select count (1) fromuserinfowhereuserid=' ' uname ' ' and userpwd=' ' upwd ' '; 创建命令对象mysqlcommandmysqlcommand=newmysqlcommand (SQL,conn ); //sql语句和目标conn.Open (; //执行最晚打开、最早关闭//命令,返回结果集中第一行第一列的值,忽略其他行或列objecto=MySQL command.executescalar (); //执行存储过程//MySQL command.commandtype=commandtype.stored procedure; //关闭连接conn.Close (; //处理结果//根据返回的结果而不同的提示if (o==null|| o==dbnull.value|| convert.toint 32 (o )==0) { MessageBox.Show } else { MessageBox.Show (“登录成功”、“成功提示”、MessageBoxButtons.OK和MessageBoxIcon.Information ); 执行//命令//关闭连接//处理结果} privatevoidbtn _ exit _ click (对象发送器,事件e ) { this.Close ); //关闭具有启动窗口的页面//Application.Exit (; //关闭此窗口//Application.ExitThread (; //是否关闭提示} }因为使用的是MySQL数据库,所以需要引入MySQL的命名空间

usingMySQL.data.MySQL客户端;

要获取用户输入数据,请执行以下操作:

//获取用户输入信息string uname=txt userid.text.trim (; //确定是否为空,设置值为空或空的字符串if(string.isnullorempty(uname ) )//提示框的标题和提示信息,然后单击消息提示框中的图标messagebox 请再输入一次!' 、“登录提示”、MessageBoxButtons.OK和MessageBoxIcon.Error; txtUserId.Focus (; //对焦返回; //建立与数据库的连接//连接字符串,---密钥string connstring=' data source=localhost; 数据库=student db; 用户id=root; password=admin; charset=utf8 '; mysqlconnectionconn=newmysqlconnection (connstring ); //写入查询语句string SQL=' select count (1) fromuserinfowhereuserid=' ' uname ' ' and userpwd=' ' upwd ' '; 创建命令对象mysqlcommandmysqlcommand=newmysqlcommand (SQL,conn ); //sql语句和目标conn.Open (; //执行最晚打开、最早关闭//命令,返回结果集中第一行第一列的值,忽略其他行或列objecto=MySQL command.executescalar (); //执行存储过程//MySQL command.commandtype=commandtype.stored procedure; //关闭连接conn.Close (; //处理结果if (o==null|| o==dbnull.value|| convert.toint 32 (o )==0) ) { MessageBox.Show帐户或密码错误}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。