#include <iostream> 
#include <string>

using namespace std;

class w {

    void InsertRow(String* myConnection)
        // If the connection string is null, use a default.
        if (myConnection->Equals(S""))
            myConnection = S"DRIVER= {SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=idb;";
        OdbcConnection* myConn = new OdbcConnection(myConnection);
        String* myInsertQuery = S"INSERT INTO test (id)";
        OdbcCommand* myOdbcCommand = new OdbcCommand(myInsertQuery);
        myOdbcCommand->Connection = myConn;

hai i m trying to connect visual studio C++ to mysql, i m using odbc method... i have connect the database to the visual studio, but i dnt know the code need to connect in the c++ ( example for vb.net we will use the dim.... database name all and establish connection) i need the same thing in c++,

i have try this code ealier post above but its not working>..

Edited by Nick Evan: Merged posts, split thread, added CODE-tags

8 Years
Discussion Span
Last Post by tesuji

You need to start learning ODBC in C from a tutorial. Lots of them on the net, including this one. Its a lot more difficult than what you knew in VB, so be patient and study the tutorial.

There are a few c++ wrapper classes to make it a little easier for you. Just google for them and you will find them. Some are free but some are not.

And for the record VC++ is not a language. Its just an IDE and compiler which lets you write standard c++ and c code. You shouldn't confuse the two.

Edited by Ancient Dragon: n/a



we had similar question recently. You may look here. Possibly you already know this older post by yourself.

If you don't like classless plain odbc (mysql: Connector/ODBC) you could make use of mysql: Connector/C++. There are also nice tutorials on Connector/C++.

-- tesu

Edited by tesuji: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.