I'm searching for a totally free mix-platform (Home windows, Linux) C++ library to have an use of an MS SQL server DB.

For instance, I wish to convert the next C# flow to unmanaged C or C++ (from here) :

static void Main()
{
    string connectionString = 
       ConsoleApplication746.Properties.Settings.Default.ConnectionString;
    using (SqlConnection con = new SqlConnection(connectionString))
    {
        con.Open();
        using (SqlCommand command = 
           new SqlCommand("SELECT TOP 2 * FROM Dogs1", con))
        using (SqlDataReader reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                 Console.WriteLine("{0} {1} {2}", reader.GetInt32(0),
                    reader.GetString(1), reader.GetString(2));
            }
        }
    }
}

Try DTL or SOCI.

Edit: or OTL.

Being able to access MS SQL server from home windows should not be any condition in general. For being able to access it from Linux, this web site will let you to find away out

http://www.sommarskog.se/mssqlperl/unix.html

Getting a solution that creates both Home windows and Linux is really a task that won't be solved easily, is dependent around the exact needs as well as your current architecture. For instance, when you simply need C++ program calling a Perl script which does the DB meet your needs, this path may supply you with a free mix-platform solution. Perl is free of charge and mix-platform, and also the DBI modules too.

However, whenever your mix-platform C++ program utilizes a mix-platform framework like Qt, and you'll need a direct connection inside your C++ program towards the SQL server, ODBC might be the best choice:

http://doc.qt.nokia.com/4.7/sql-driver.html

Regrettably, based on the information behind my first link, you will find no free ODBC motorists for Linux, so you may bite the bullet and purchase one.

Indeed, SQLite is definitely an implementation of the DB where information is saved inside a flat file.

I believe ODBC may be the technology you are searching for.

How about SQLAPI++? Works both on Home windows and Linux/Unix. http://www.sqlapi.com/.

There's pointless to rewrite perfectly good, examined, working code.

Do not do it. Use Mono to operate your overall code on Unix/Linux rather.