If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > VS.NET C# & MySQL connection errors - Please help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-05, 16:02
holyinsomniac holyinsomniac is offline
Registered User
 
Join Date: Jan 2005
Posts: 1
Question VS.NET C# & MySQL connection errors - Please help

Hello,

I have been trying to fix this issue for quiet some time now. You will see the error below. Here is what I have done already.
1. I have ODBC 3.51 Driver installed
2. I have MySQL 4.1.8 installed with username root and testuser.
3. I have also created an ODBC DSN named TestLocalDB under the user and the system DSN. The connection works fine when I test it under ODBC Data Source Administrator.
4. I am using C# to connect to the DB using ODBC. Here is my code:

Quote:
private void Button1_Click(object sender, System.EventArgs e)
{
OdbcConnection myConn = new OdbcConnection("DSN=TestLocalDB");
string myInsertQuery = "INSERT INTO Login_Info (user_id, password) Values('test', 'password')";
OdbcCommand myOdbcCommand = new OdbcCommand(myInsertQuery);
myOdbcCommand.Connection = myConn;
myConn.Open();
myOdbcCommand.ExecuteNonQuery();
myOdbcCommand.Connection.Close();
}
Also, when I run the mysqladmin command from the prompt, I get the following along with other stuff:

Quote:
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
count 0
force FALSE
compress FALSE
character-sets-dir (No default value)
host (No default value)
port 3306
relative FALSE
shared-memory-base-name (No default value)
socket (No default value)
sleep 0
user (No default value)
verbose FALSE
vertical FALSE
connect_timeout 43200
shutdown_timeout 3600
As you may notice that for the user, there is No default value. How can I fix that??


::HERE IS THE ERROR::

Quote:
Server Error in '/TestApp' Application.
--------------------------------------------------------------------------------

ERROR [HYT00] [MySQL][ODBC 3.51 Driver]Access denied for user 'ODBC'@'localhost' (using password: NO)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [HYT00] [MySQL][ODBC 3.51 Driver]Access denied for user 'ODBC'@'localhost' (using password: NO)

Source Error:


Line 53: OdbcCommand myOdbcCommand = new OdbcCommand(myInsertQuery);
Line 54: myOdbcCommand.Connection = myConn;
Line 55: myConn.Open();
Line 56: myOdbcCommand.ExecuteNonQuery();
Line 57: myOdbcCommand.Connection.Close();


Source File: c:\documents and settings\sprint\vswebcache\chsf47vrl21\testapp\web form1.aspx.cs Line: 55

Stack Trace:


[OdbcException: ERROR [HYT00] [MySQL][ODBC 3.51 Driver]Access denied for user 'ODBC'@'localhost' (using password: NO)]
System.Data.Odbc.OdbcConnection.Open()
TestApp.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\documents and settings\sprint\vswebcache\chsf47vrl21\testapp\web form1.aspx.cs:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Last edited by holyinsomniac; 01-07-05 at 16:07.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On