1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace ConsoleApplication4
{
class Program
{
    static void Main(string[] args)
    {
        string con = "Server=mysql.2freehosting.com;Database=u772631349_vadi;Uid=u772631349_vadi;password=password";
        MySqlConnection conn = new MySqlConnection(con);
        try
        {
            conn.Open();


        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        } 

        Console.Read();
    }
}

this code on running threw me an exception "Object reference not set to an instance of am object"...I'm just trying to access to my serves's mysql database..

  • `NullReferenceException` is a common situation for beginner programmers. The link provided should help you understand the problem. Then use the debugger to find what/where/when you have a variable that is `null`. – Soner Gönül Jan 29 '15 at 07:01

1 Answers1

0

have you tried replacing uid for user id?

string con = "server=mysql.2freehosting.com;Database=u772631349_vadi;user id=u772631349_vadi;password=password";

not sure if this is the solution - looks ok to me.

nologo
  • 5,015
  • 3
  • 33
  • 47