MySQL Forums
Forum List  »  Knowledge Base

unhandled error from mysql_next_result()
Posted by: Dmitriy Reznik
Date: February 22, 2010 08:50AM

Dear friends,

I get the following exception
unhandled error from mysql_next_result()
on closing odbc reader. Could anybody tell me please what is wrong? Here is the code:

int inserted = 0;
int updated = 0;
int rowCounter = 0;
OdbcDataReader odbcReader = null;

try
{
String odbcConnString = WebConfigurationManager.ConnectionStrings["BookList"].ToString();
odbcConnection = new OdbcConnection(odbcConnString);

OdbcCommand odbcCommand = new OdbcCommand("{ CALL InsertBookQuest(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }", odbcConnection);

odbcCommand.CommandType = CommandType.StoredProcedure;

if (odbcConnection.State == ConnectionState.Closed)
odbcConnection.Open();

for (rowCounter = 0; rowCounter < sheetEntries.GetLength(0); rowCounter++)
{
odbcCommand.Parameters.Clear();

OdbcParameter odbcParameter = odbcCommand.Parameters.Add("pEAN", OdbcType.VarChar, 13);
odbcParameter.Value = sheetEntries[rowCounter, 0] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 0];
odbcParameter = odbcCommand.Parameters.Add("pTitle", OdbcType.VarChar, 255);
odbcParameter.Value = sheetEntries[rowCounter, 1] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 1];
odbcParameter = odbcCommand.Parameters.Add("pRespParty", OdbcType.VarChar, 255);
odbcParameter.Value = sheetEntries[rowCounter, 2] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 2];
odbcParameter = odbcCommand.Parameters.Add("pPublisher", OdbcType.VarChar, 255);
odbcParameter.Value = sheetEntries[rowCounter, 3] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 3];
odbcParameter = odbcCommand.Parameters.Add("pPubDate", OdbcType.SmallDateTime);
odbcParameter.Value = sheetEntries[rowCounter, 4] == "" ? (object)DBNull.Value : Convert.ToDateTime(sheetEntries[rowCounter, 4]);
odbcParameter = odbcCommand.Parameters.Add("pSubject", OdbcType.VarChar, 255);
odbcParameter.Value = sheetEntries[rowCounter, 5] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 5];
odbcParameter = odbcCommand.Parameters.Add("pBinding", OdbcType.VarChar, 45);
odbcParameter.Value = sheetEntries[rowCounter, 6] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 6];
odbcParameter = odbcCommand.Parameters.Add("pPageCount", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 7] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 7]);
odbcParameter = odbcCommand.Parameters.Add("pUSListPrice", OdbcType.Double);
odbcParameter.Value = sheetEntries[rowCounter, 8] == "" ? (object)DBNull.Value : Convert.ToDouble(sheetEntries[rowCounter, 8]);
odbcParameter = odbcCommand.Parameters.Add("pDemand", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 9] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 9]);
odbcParameter = odbcCommand.Parameters.Add("pOnOrder", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 10] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 10]);
odbcParameter = odbcCommand.Parameters.Add("pOnBackorder", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 11] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 11]);
odbcParameter = odbcCommand.Parameters.Add("pStatus", OdbcType.VarChar, 45);
odbcParameter.Value = sheetEntries[rowCounter, 13] == "" ? (object)DBNull.Value : sheetEntries[rowCounter, 13];
odbcParameter = odbcCommand.Parameters.Add("pBTKey", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 14] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 14]);
odbcParameter = odbcCommand.Parameters.Add("pBTFirstPrinting", OdbcType.Int);
odbcParameter.Value = sheetEntries[rowCounter, 15] == "" ? (object)DBNull.Value : Convert.ToInt32(sheetEntries[rowCounter, 15]);

odbcReader = odbcCommand.ExecuteReader();

if (odbcReader.Read())
{
if (Convert.ToBoolean(odbcReader["IsInsert"]) == true)
inserted++;
else
updated++;
}

if (odbcReader != null && !odbcReader.IsClosed)
odbcReader.Close();

}

Options: ReplyQuote


Subject
Views
Written By
Posted
unhandled error from mysql_next_result()
5432
February 22, 2010 08:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.