Posts tagged ‘mysql’

MySql in C#

First download the Mysql ODBC driver from the download page.

Then download the .net connector, at this writing it was Mysql Connector/Net 5.2

You can choose to download only the binaries, extract and add /bin/MySql.Data.dll to your project. A help file for the classes is found at /Docs/MySql.Data.chm of the download.

With the dll added to the project, it’s very simple to connect to a MySql database as the snippet below.

using MySql.Data.MySqlClient;

namespace test
{
    class testit
    {
        private MySqlConnection mConn = null;
        private const string msConnStr = “SERVER=myserv.com” +
            “;DATABASE=somedbase;UID=theuser;PWD=thepassword”;

        public void test()
        {
            try
            {
                // Setup and open acceess to the database
                mConn = new MySqlConnection(msConnStr);
                mConn.Open();
                // simple count select
                MySqlCommand command = new MySqlCommand(“select count(*) from cars”, mConn);
                long ret = (long)command.ExecuteScalar();
                // how many rows in the table
                Console.WriteLine(“cars count=” + ret );
            }
            catch (Exception ex)
            {
                Console.WriteLine(“err=” + ex);
            }
            finally
            {
                if( mConn != null ) mConn.Close();
            }
        }

Servlet Authenticator problem – part 2

I had a problem at the hosting place with an authenticated http request. Now 5 days later it’s finally solved.  5 days mind you is a long time.  It goes something like this.

1. Send in a support request.

2. Wait until the next day.

3. Get answer from a junior person claiming they don’t understand the problem well enough.

4. Repeat

Until finally a senior person or a “tech” takes a look at the problem and solves it.   In other words 5 emails and 5 days later my problem is finally solved, not good.  Yes my place is cheap and has a nice cPanel were you can do most of the administration yourself.  Setup MySql, subdomains, email forwards etc, but if you need help from support…

Anyway, the java servlet is now running, it will pull up my tweet feed and read it to you on the phone.  You can call it here 720-897-8900 or skype call it +990009369990026351

And on a less happier note, LinuxHaters is closing shop.  I’m thinking about doing a petition, any takers ?