baijajusav
asked on
Memory allocation error from MySql ODBC 5.1 driver in ASP .NET C# application on insert statement
I have a ASP .NET application in C#. It's a simple web application that is using the MySql 5.1 database community edition. I've downloaded the MySql ODBC driver and have created a dsn to my database on my local machine. On my website, I can perform get type queries without problems, but when I execute a given insert statement (not that I've tried doing any others), I get the following error:
{"ERROR [HY001] [MySQL][ODBC 5.1 Driver][mysqld-5.1.30-comm unity]Memo ry allocation error"}
I've tried switching everything over to the MyISam engine and increasing memory allocation where I could see it was used; however, I've got no idea why this is being caused.
I'm running on a Windows XP machine. My machine has 4 GB of memory (only 3 GB detected due to 32 bit).
I'm using MySql Administrator and am watching the connections and every time I open a connection, I see about 5 connections listed to the database. All of my methods close the connection too.
Anyone have any ideas? See code below
{"ERROR [HY001] [MySQL][ODBC 5.1 Driver][mysqld-5.1.30-comm
I've tried switching everything over to the MyISam engine and increasing memory allocation where I could see it was used; however, I've got no idea why this is being caused.
I'm running on a Windows XP machine. My machine has 4 GB of memory (only 3 GB detected due to 32 bit).
I'm using MySql Administrator and am watching the connections and every time I open a connection, I see about 5 connections listed to the database. All of my methods close the connection too.
Anyone have any ideas? See code below
public static readonly String insertChatUser =
@"insert into chatuser
( Username, Password, Firstname, Lastname, Sex )
Values
( ?, ? , ? , ? , ?)";
public static void insertChatUser(User u)
{
OdbcConnection MyConn = DBConnection.getDBConnection();
int result = -1;
try
{
MyConn.Open();
OdbcCommand myCmd = new OdbcCommand();
myCmd.Connection = MyConn;
myCmd.CommandType = CommandType.Text;
OdbcParameter userName = new OdbcParameter("@UserName", u.UserName);
OdbcParameter password = new OdbcParameter("@Password", u.Password);
OdbcParameter firstName = new OdbcParameter("@FirstName", u.FirstName);
OdbcParameter LastName = new OdbcParameter("@LastName", u.LastName);
OdbcParameter sex = new OdbcParameter("@sex", u.Sex);
myCmd.Parameters.Add(userName);
myCmd.Parameters.Add(password);
myCmd.Parameters.Add(firstName);
myCmd.Parameters.Add(LastName);
myCmd.Parameters.Add(sex);
myCmd.CommandText = mySqlQueries.insertChatUser;
result = myCmd.ExecuteNonQuery();
}
catch (Exception e)
{
//{"ERROR [HY001] [MySQL][ODBC 5.1 Driver][mysqld-5.1.30-community]Memory
// allocation error"} EXCEPTION ALWAYS THROWN HERE
}
finally
{
try
{
if (MyConn != null) MyConn.Close();
}
finally { }
}
}
ASKER
ragi:
I did find that first article a bit after posting, but I confirmed that was not the issue. I am trying to insert nulls, but the columns where they go are nullable. The length of the data I'm inserting is shorter/smaller than the max size in the table.
The 2nd link wasn't very helpful. I have found several google entries describing this issue, but many are on linux machines and I'm yet to find a solution for a windows machine. On the mysql site, they do not have any patches that I can tell. That is where I got my odbc driver for mysql.
Thanks for chiming in, though. I'm pretty stumped so any lead will help.
I did find that first article a bit after posting, but I confirmed that was not the issue. I am trying to insert nulls, but the columns where they go are nullable. The length of the data I'm inserting is shorter/smaller than the max size in the table.
The 2nd link wasn't very helpful. I have found several google entries describing this issue, but many are on linux machines and I'm yet to find a solution for a windows machine. On the mysql site, they do not have any patches that I can tell. That is where I got my odbc driver for mysql.
Thanks for chiming in, though. I'm pretty stumped so any lead will help.
ASKER
Anyone have any ideas on this issue?
ASKER
Okay I know where the issue is. It's when I'm inserting null data. Despite that working in MySql Query Bench, it is not working here. I can, however, insert blank data. The table does allow nulls for the fields that are submitting null.
Is there a MySql specific value that needs to be used for null when working with MySql 5.1 ODBC?
Is there a MySql specific value that needs to be used for null when working with MySql 5.1 ODBC?
how are you passing the null value to the mysql stored procedure parameter
ASKER
I have something like:
OdbcParameter firstName = new OdbcParameter("@FirstName"
and u.FirstName happens to be null. When the insert is executed the out of memory exception is thrown. As a dirty fix, I have a function that checks the value for null and if it is null, it returns String.Empty instead as I'm not sure how to specifically insert a null.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
http://tomtech999.wordpress.com/2008/08/02/odbc-memory-allocation-error/
have you installed the patches for ODBC drivers ... may be the problem has been fixed and its available in some patch as a lot of people have complained about the error
http://www.google.co.in/search?hl=en&q=MySql+Memory+allocation+error&btnG=Google+Search&meta=