ODBC MySQL - Having Trouble. :(

Discussion in 'Databases' started by hexane, Jan 7, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi...

    I am trying to do a "basic" ODBC connection to my MYSQL Database being hosted at discountasp. For the life of me, I can't get anything to return... could someone lend a hand? Here is my code:

    --------------------------------

    string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
    "SERVER=hostnameatdiscountasp;" +
    "DATABASE=myassigneddatabase;" +
    "UID=;" +
    "PASSWORD=;" +
    "OPTION=3";

    OdbcConnection MyConnection = new OdbcConnection(MyConString); MyConnection.Open();

    OdbcCommand MyCommand = new OdbcCommand();
    MyCommand.CommandText = "SELECT * FROM sometesttable";

    OdbcDataReader MyDataReader;

    MyDataReader = MyCommand.ExecuteReader();

    while (MyDataReader.Read())
    {
    Label1.Text = MyDataReader.GetString(1);
    }

    MyDataReader.Close();
    MyConnection.Close();

    ----------------------------

    Any ideas on what might be the problem?

    Thanks a bunch.

    Matthew Workman
    TLWI
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Try use the DSN created with your mySQL account.

    See this KB article, http://kb.discountasp.net/article.aspx?id=10085

    quote:Originally posted by hexane

    Hi...

    I am trying to do a "basic" ODBC connection to my MYSQL Database being hosted at discountasp. For the life of me, I can't get anything to return... could someone lend a hand? Here is my code:

    --------------------------------

    string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
    "SERVER=hostnameatdiscountasp;" +
    "DATABASE=myassigneddatabase;" +
    "UID=;" +
    "PASSWORD=;" +
    "OPTION=3";

    OdbcConnection MyConnection = new OdbcConnection(MyConString); MyConnection.Open();

    OdbcCommand MyCommand = new OdbcCommand();
    MyCommand.CommandText = "SELECT * FROM sometesttable";

    OdbcDataReader MyDataReader;

    MyDataReader = MyCommand.ExecuteReader();

    while (MyDataReader.Read())
    {
    Label1.Text = MyDataReader.GetString(1);
    }

    MyDataReader.Close();
    MyConnection.Close();

    ----------------------------

    Any ideas on what might be the problem?

    Thanks a bunch.

    Matthew Workman
    TLWI
    </blockquote id="quote"></font id="quote">
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page