[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Strange empty warning message boxes...

cedric.delnibbio

7/27/2006 2:17:00 PM

Hi every body !

I came across a tremendous problem which is new to me. Any workaround
to get rid of the following troubleshoot would be helpful.

When the following code is running in my application, I sometimes have
the surprise to discover empty warning message boxes, which contain
only the warning Icon and an OK button. I pointed the guilty lines by a
commentary line where these boxes might appear in the three sub
functions below.
When you press the OK button, the application continues. The line which
seems to have generated the empty message proceeded correctly, as the
informations are correct in the database.

As I was wondering where these windows might come from, I discovered
another tremendous thing : these message boxes have no parent window !

Did anyone come across this kind of problem ? My application may run
for a long time, so nobody is to wait for a message box to click on in
order to go further in the application ! Moreover, these windows are
appearing only when they want, and I couldn't find out any systematic
event... Any idea ?

So, here is my configuration :
- Database : SYBASE 12.x
- C# window based project using VS 2003.
- Windows XP Pro

One of the modules of my application uses the following code :

// Declare the connectionstring
string str = "DSN=PAGE_DB;UID=xxxxxxxx;PWD=xxxxxxxx;DB=ref_DB";
System.Text.StringBuilder stringB = new System.Text.StringBuilder();
// Create the ODBC Connection
OdbcConnection localOdbcConnection = new OdbcConnection(str);
localOdbcConnection.Open();
// Create temporary table - see below the code
CreateTempTable(localOdbcConnection);
DataTable AllValues;
// Loop over a previous DataTable
foreach(DataRow row in dtInv.Rows)
{
stringB.Append("INSERT INTO #InternalCodeList (InternalCode) VALUES
(" + row["InternalCode"].ToString() + ")");
}
// If something is to be done...
if(stringB.ToString() != "")
{
ExecuteQuery(stringB.ToString(), localOdbcConnection);
// Create a DataTable using a DataAdapter - see below
AllValues = Fill("EXEC ref_DB.dbo.get_AllValues 0",
localOdbcConnection);
}
// Fill the result DataTable using a DataAdapter
DataTable dtTemp = Fill("SELECT * FROM #CodeInterneList ",
localOdbcConnection);
// Drop temporary table
ExecuteQuery("DROP TABLE #InternalCodeList ", localOdbcConnection);
localOdbcConnection.Close();

Here are the three sub functions CreateTempTable, ExecuteQuery and Fill
:

private void CreateTempTable(OdbcConnection gConnection)
{
// Sometimes the strange windows are shown there... But never on the
first time the function is called...
ExecuteQuery("CREATE TABLE #CodeInterneList ( InternalCode INT NULL,
TransCode Varchar(20) NULL )", gConnection);
}

private void ExecuteQuery(string gQuery, OdbcConnection gConnection)
{
try
{
OdbcCommand comm = new OdbcCommand(gQuery, gConnection);
// Sometimes the strange windows are shown there...
comm.ExecuteNonQuery();
}
catch(OdbcException exc)
{
System.Windows.Forms.MessageBox.Show(exc.Message, "Page",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error);
}
}

private DataTable Fill(string gQuery, OdbcConnection gConnection)
{
DataTable returnDT = new DataTable();
try
{
OdbcDataAdapter da = new OdbcDataAdapter(gQuery, gConnection);
// Sometimes the strange windows are shown there...
da.Fill(returnDT);
}
catch(OdbcException exc)
{
System.Windows.Forms.MessageBox.Show(exc.Message, "Page",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error);
}
return returnDT;
}

Thanks for reading,

Cédric