急求:关于MFC对MYSQL数据库的相关 *** 作问题(软件:vs2010)

急求:关于MFC对MYSQL数据库的相关 *** 作问题(软件:vs2010),第1张

应该是字符集的问题, 这个语句的字符集应该是 GB2312

连接的时候或者执行之前要先设置字符集,比如下边这句试一下:

mysql_query("set names gb2312");

用单引号 即可 ' ' 不需要 转义符"\";

unicode 转 吧, 转成utf8 的

至于方法 参考百度 这个可烦人了

或者干脆建立工程的时候 就不要选择unicode

-------------------------------------------------------------------

先执行一个 mysql_query(&db_my,"set name gbk"); 试试~

private void Loginbutton_Click(object sender, EventArgs e)

        {

            if (GongHaotextBoxTextTrim() == "" || MiMatextBoxTextTrim() == "")

            {

                MessageBoxShow("请输入工号或者密码!", "错误提示");

            }

            else

            {

                string gonghao = thisGongHaotextBoxTextTrim();

                string mima = thisMiMatextBoxTextTrim();               

                bool flag1 = false;

                try

                {

                    //SqlConnection conn = new SqlConnection("Data Source=PC-20150105JSGS;Persist Security Info=True;Initial Catalog=yuangonglogin;User ID=sa;Password=sql");

                    string conn = "Data Source=gd;Persist Security Info=True;Initial Catalog=工资管理系统;User ID=sa;Password=sql";

                    SqlConnection sqlcnt = new SqlConnection(conn);

                   // sqlcntConnectionString = ConfigurationManagerConnectionStrings["strcnt"]ConnectionString;

                    sqlcntOpen();

                    SqlCommand scomm = new SqlCommand();//初始化SQL命令对象

                     scommCommandText = "select  from yuangonglogin where 工号 ='" + thisGongHaotextBoxText + "' and 密码='" + MiMatextBoxText + "'";

                     scommCommandType = CommandTypeText;//SQL执行类型

                     scommConnection = sqlcnt;//命令执行所在的connection

                     SqlDataReader rd = scommExecuteReader();//开始执行语句                   

                     while(rdRead())

                     {

                         if ((gonghao == rd["工号"]ToString()Trim()) &&( mima == rd["密码"]ToString()Trim()))

                         {

                             flag1 = true;

                             break;                            

                         }

                     }

                     

                    if (flag1)

                     {

                         MessageBoxShow("登录成功");

                         rdClose();//关闭read游标

                         sqlcntClose();//关闭connection连接

                         Form2 nForm = new Form2();

                         nFormShow();

                         thisHide();

                     }

                     else

                     {

                         MessageBoxShow("用户名或者密码错误!","错误提示");

                         rdClose();//关闭read游标

                         sqlcntClose();//关闭connection连接

                     }                    

                }

                catch (Exception oExcept)

                {

                    MessageBoxShow(oExceptMessage);

                }//

            }

        }

以上就是关于急求:关于MFC对MYSQL数据库的相关 *** 作问题(软件:vs2010)全部的内容,包括:急求:关于MFC对MYSQL数据库的相关 *** 作问题(软件:vs2010)、mfc向mysql中插入中文数据,但是执行不了含中文的sql语句、用VS2010的MFC做的登录框,怎样去跟mysql数据库链接,检测输入的用户名密码是否正确等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10184742.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-06
下一篇 2023-05-06

发表评论

登录后才能评论

评论列表(0条)

保存