[RESOLVED] ERROR - VS 2012 MFC dialog based application connect with MYSQL
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: [RESOLVED] ERROR - VS 2012 MFC dialog based application connect with MYSQL

  1. #1
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    [RESOLVED] ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Hi,

    I'm using VS 2012. Installed MYSQL 5.6, C++ Connector 1.1.3. Created a sample table using mysql. Now i like to create a connect between mysql and MFC dialog. Using this, i was try to connect.

    Server Explorer -> Data Connection -> Add Connections ->MYSQL Database -> Addconnection
    To get the connection, i want to enter the connection settings like:
    server host name = localhost, user name =root, password=
    if i pressed any letter in the keyboard means add connection dialog was colosed automatically.

    How to connect mysql(localhost) with MFC Dialog?

    pls help me.
    Regards,

    SaraswathiSrinath

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Server Explorer is not a wizard for adding connection to your app. It is about exploring your database in Visual Studio itself.
    Best regards,
    Igor

  3. #3
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    First i try to connect using this code But dialog based application instead of Console Application.
    Kindly find the attchment. I already done this code in a console application with windows xp & VC6. Its worked.

    Added C++
    C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\include
    C:\Program Files\MySQL\MySQL Server 5.6\include
    C:\Program Files\boost_1_55_0

    Added Linker - > general
    C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\lib\opt

    linked mysqlcppconn.lib
    if not added C:\Program Files\boost_1_55_0 error occured like
    fatel error C1083 can not open include file 'boost/variant.cpp' no such file or directory.

    if added
    1>------ Build started: Project: VCMysqlConn, Configuration: Release Win32 ------
    stdafx.cpp
    VCMysqlConn.cpp
    VCMysqlConnDlg.cpp
    c:\program files\mysql\mysql connector c++ 1.1.3\include\cppconn\sqlstring.h(38): warning C4251: 'sql::SQLString::realStr' : class 'std::basic_string<_Elem,_Traits,_Alloc>' needs to have dll-interface to be used by clients of class 'sql::SQLString'
    with
    [
    _Elem=char,
    _Traits=std::char_traits<char>,
    _Alloc=std::allocator<char>
    ]
    C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\include\cppconn/exception.h(61): warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Alloc>' needs to have dll-interface to be used by clients of class 'sql::SQLException'
    with
    [
    _Elem=char,
    _Traits=std::char_traits<char>,
    _Alloc=std::allocator<char>
    ]
    VCMysqlConnDlg.cpp(206): fatal error C1075: end of file found before the left brace '{' at VCMysqlConnDlg.cpp(177)' was matched
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    how can i link ?
    Attached Files Attached Files
    Regards,

    SaraswathiSrinath

  4. #4
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Followed Dynamic build concept and solved the compile time error.

    Now Run time error occured like.
    The Procedure entry point?? /sqlstring@sql @@AE could not be located in the dynamic link libraries
    Kindly find the attachment and give some solutions.
    Attached Images Attached Images  
    Regards,

    SaraswathiSrinath

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Well, you did something wrong since now system searches for the MzSQL functions not in mysqlcppconn.dll where they appear to be but in your own executable DLGDBCONN.exe.
    Besides, why did you start with the release build rather than the debug one?
    Victor Nijegorodov

  6. #6
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Quote Originally Posted by VictorN View Post
    why did you start with the release build rather than the debug one?
    Yes I'm using release mode becos, Msdn tells
    To avoid potential crashes, the build configuration of MySQL Connector/C++ should match the build configuration of the application using it. For example, do not use the release build of MySQL Connector/C++ with a debug build of the client application.
    I was manually copied the lib files in the release folder and run my application, it was opened.

    any solution for this error?
    Last edited by saraswathisrinath; May 22nd, 2014 at 02:04 AM. Reason: update soln
    Regards,

    SaraswathiSrinath

  7. #7
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    I have both version of VS2003 & VS 2012 in my PC.
    Compination of win 8 + VS 2012, mysql 5.6(32 bit), connector 1.1.3(32 bit) & Booster 1.55.0 -> No compile time error both mode(release & Debug). But run time error like The Application was unable to start correctly oxc000007b. click ok to close the application. in VS2012 console application.

    If i was develop the same application in win 8 + VS2003 means, running good both mode(release & Debug).

    My requirement is mysql data base connection with VS2012 Dialog based MFC application.

    I reinstalled the 32 bit version mysql & Connector and installed the 64 bit version mysql 5.6 & connector 1.1.3. After setting, compile time error occured both debug mode & Release mode in VS2012 & VS2003.

    Pls suggest any solutions. I'm helpless.
    Regards,

    SaraswathiSrinath

  8. #8
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Used the bellow connection string for Remote database,
    Code:
    sDsn.Format("Driver={MySQL ODBC 5.2 ANSI Driver};Server=20.240.10.10;Database=sara;User=root;Password=client;Option=3;");
    Error occurred like
    Connection Failed HY000 MYSQL ODBC 5.2(a) Driver can't connect to MySQL server on 20.240.10.10 (10060)
    how can I establish the handshaking between system1 & system2 ?

    System1 used wireless connection & System2 used wired connection[Ethernet].
    used the ipconfig command to get the IP address. any issue arise, for using IP instead of IP4 for server name.
    Regards,

    SaraswathiSrinath

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Perhaps, the Firewall problems?
    Victor Nijegorodov

  10. #10
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Quote Originally Posted by VictorN View Post
    Perhaps, the Firewall problems?
    I was enabled firewall on both server & client PC.
    Firewall setting via terminal:
    Code:
    C:\Windows\System32>netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306
    For reference, Mysql Statements in server PC,[ client IP: 152.148.100.197 & server IP: 14.99.188.146]
    Code:
    mysql> GRANT ALL ON *.* TO 'root'@'152.148.100.%';
    mysql> FLUSH PRIVILEGES;
    mysql> show grants;
    +------------------------------------------------------------------------------------------------------------------
    ----------------------+
    | Grants for root@localhost
                          |
    +------------------------------------------------------------------------------------------------------------------
    ----------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D6150294
    41' WITH GRANT OPTION |
    | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
                          |
    +------------------------------------------------------------------------------------------------------------------
    ----------------------+
    2 rows in set (0.00 sec)
    
    
    mysql> select host, user from mysql.user;
    +-----------------+-------+
    | host            | user  |
    +-----------------+-------+
    | %.%.%.%         | root  |
    | 127.0.0.1       | root  |
    | 14.%.%.%        | root  |
    | 152.%.%.%       | root  |
    | 152.148.100.197 | root  |
    | localhost       | root  |
    +-----------------+-------+
    11 rows in set (0.00 sec)
    
    
    mysql> select user();
    +----------------+
    | user()         |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)
    
    
    mysql> select current_user(
    +----------------+
    | current_user() |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)
    
    
    mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
    +-----------------+------+-------------------------------------------+------------+------------+
    | host            | user | password                                  | Grant_priv | Super_priv |
    +-----------------+------+-------------------------------------------+------------+------------+
    | localhost       | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 | Y          | Y          |
    | 127.0.0.1       | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 | Y          | Y          |
    | 152.%.%.%       | root | *459DEC76B4BAF7C0DCE265EDCA7EB68442C45E78 | Y          | Y          |
    | %               | root | *459DEC76B4BAF7C0DCE265EDCA7EB68442C45E78 | Y          | Y          |
    | 152.148.100.197 | root | *459DEC76B4BAF7C0DCE265EDCA7EB68442C45E78 | Y          | Y          |
    | 152.148.100.%   | root | *459DEC76B4BAF7C0DCE265EDCA7EB68442C45E78 | Y          | Y          |
    | 14.%.%.%        | root | *459DEC76B4BAF7C0DCE265EDCA7EB68442C45E78 | Y          | Y          |
    | 14.99.188.146   | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 | Y          | Y          |
    +-----------------+------+-------------------------------------------+------------+------------+
    8 rows in set (0.00 sec)
    
    C:\Windows\system32>netstat -anto | findstr 3306
      TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       6220     InHost
      TCP    [::]:3306              [::]:0                 LISTENING       6220     InHost
      TCP    [::1]:3306             [::1]:59613            ESTABLISHED     6220     InHost
      TCP    [::1]:59613            [::1]:3306             ESTABLISHED     1508     InHost
    The above same grant permission done in client PC.
    In terminal, Server PC
    Code:
     ping 152.148.100.197 -t 
    request time out
    In terminal,Client PC
    Code:
     ping 14.99.188.146-t 
    Reply from 14.99.188.146: bytes=32 time=1ms TTL=128
    Still i was not connect remotely. pls help me.
    Regards,

    SaraswathiSrinath

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    This is Visual C++ forum, not MySQL. You'd better ask this on more appropriate forums. Or read documentation from Oracle.
    Best regards,
    Igor

  12. #12
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Quote Originally Posted by Igor Vartanov View Post
    This is Visual C++ forum, not MySQL. You'd better ask this on more appropriate forums. Or read documentation from Oracle.
    I Like to access MYSQL database using MFC dialog based application only. I thought i was mistaken in mysql side , so i post mysql commands.
    Last edited by saraswathisrinath; June 20th, 2014 at 10:50 PM.
    Regards,

    SaraswathiSrinath

  13. #13
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Man, it doesn't matter using what framework or application type you try to achieve this. What really matters is connectivity technology and database configuration. Both aspects are about MySQL, and this is what you should focus on. The sooner you understand this, the better you solve your issue.
    Best regards,
    Igor

  14. #14
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Quote Originally Posted by Igor Vartanov View Post
    Man, it doesn't matter using what framework or application type you try to achieve this. What really matters is connectivity technology and database configuration. Both aspects are about MySQL, and this is what you should focus on. The sooner you understand this, the better you solve your issue.
    Really i don't know how to solve this. so only i was post. Thanks Mr. Igor. I will try.
    Regards,

    SaraswathiSrinath

  15. #15
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: ERROR - VS 2012 MFC dialog based application connect with MYSQL

    Quote Originally Posted by Igor Vartanov View Post
    What really matters is connectivity technology and database configuration. Both aspects are about MySQL, and this is what you should focus on.
    I accept. Finally i solved Mr.Igor. Thanks.
    Regards,

    SaraswathiSrinath

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center