title: Insertion of data in mysql with C#
body: <p>I am using Visual Studio 2010 c# to insert huge amount of binary data in mysql database, but when inserting I am getting the following error:</p>
  
  <blockquote>
    <p>Exception is+ The connection has been disabled.StackTrace= at
    System.Data.Odbc.OdbcConnection.ConnectionIsAlive(Exception
    innerException) at
    System.Data.Odbc.OdbcConnection.HandleErrorNoThrow(OdbcHandle
    hrHandle, RetCode retcode) at
    System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle,
    RetCode retcode) at
    System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior
    behavior, String method, Boolean needReader, Object[] methodArguments,
    SQL_API odbcApiMethod) at
    System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior
    behavior, String method, Boolean needReader) at
    System.Data.Odbc.OdbcCommand.ExecuteNonQuery() at
    UploadFile.btnFileUpload_Click1(Object sender, EventArgs e) in
    c:\inetpub\wwwroot\computingClient\UploadFile.aspx.cs:line 133</p>
  </blockquote>
  
  <p>Mysql datatype is LONGBLOB
  Here is my code:</p>
  
  <pre><code>string connStr = ConfigurationManager.AppSettings["connectionString"];
  OdbcConnection conn = new OdbcConnection(connStr);
  conn.Open();
  OdbcCommand cmd = conn.CreateCommand();
  string sql = "insert into uploadeddata values(?,?,?,?,?)";
  //cmd.CommandText = "insert into uploadeddata values(0 ,'" + fileName + "'," + id +",'"+strTokens +"')";
  cmd.CommandText = sql;
  cmd.Parameters.AddWithValue("@id", 0);
  cmd.Parameters.AddWithValue("@filename", fileName);
  cmd.Parameters.AddWithValue("@ServerKey", id);
  cmd.Parameters.AddWithValue("@Token", strTokens);
  cmd.Parameters.AddWithValue("@userId", Session["LoggedInUserId"]);
  //Logger.writeLog(@"D:\Cloud Computing\CloudClient\Log\Log.txt","id:"+id+",filename:"+fileName+",userid:"+Session["LoggedInUserId"]+",strtokens:"+strTokens);
  cmd.ExecuteNonQuery();
  conn.Close();
  progressCounter = 100;
  //progress.SecondaryValue = progressCounter;
  //progress.SecondaryPercent = progressCounter;
  string script = "&lt;script&gt;alert('File uploaded successfully');&lt;/script&gt;";
  ClientScript.RegisterClientScriptBlock(this.GetType(), script, script);
  </code></pre>