PDA

View Full Version : ODBC MySQL - Having Trouble. :(


hexane
01-07-2004, 01:04 AM
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

bruce
01-07-2004, 08:12 AM
Try use the DSN created with your mySQL account.

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

[b]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">