[lnkForumImage]
TotalShareware - Download Free Software

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


 

Teotti Enrico

11/21/2002 10:12:00 AM

Hi,
I send a piece of code that create a stange situation...

string query = querySelect();

if (query != null)
{
// Stabilisco connessione al database
OdbcConnection myConnection = new OdbcConnection
(this.connString);
// Creo il DataSet
DataSet ds;
try
{

OdbcCommand myCommand = new OdbcCommand(query,
myConnection);
// Apro la connessione
myConnection.Open ();
// Istanzio il DataSet
ds = new DataSet();
// Creo il DataAdapter
OdbcDataAdapter adapter = new OdbcDataAdapter();
// Assegno al DataAdapter il comando
adapter.SelectCommand = myCommand;
// Assegno al DataSet il risultato della interrogazione
adapter.Fill(ds, this.myIdentificativo);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Eccezione in
esecuzione Query caricamento contenitori.",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
ds = null;
}
finally
{
myConnection.Close();
}
return ds;
}
// Valore non valido
else
{
return null;
}

ok, I debug this... after filling the adapter
(this.myIdentificativo is not null) it goes in the finally
block, execute the return and give the value to the line
with the (*):

ricercaC myCont = new ricercaC();
this.identificativo = myCont.valIdent;
this.chiavePrimaria = myCont.valKey;
// Inserisco la chiave di ricerca
myCont.Codice = "001";
//Console.WriteLine("ciao"); this is the test but
it //didn't work
(*)this.dataGrid1.SetDataBinding(myCont.caricaAdesso(),
this.identificativo);// i've got the error here
this.dataGrid1.TableStyles.Clear();
this.dataGrid1.TableStyles.Add(myCont.impostazioneStile());

There I've got this error:
An unhandled exception of
type 'System.NullReferenceException' occurred in
MustHt.Flexicom.GestioneArchivio.exe

Additional information: Object reference not set to an
instance of an object.

Someone knows how could it be?
Thanks in advance,
Enrico