Hi everyone, got a problem here. Hope you can help :D
The software I'm creating manage simple movies information, this form in particoular should edit the data of a given movie. Through the code below, a form is populated with the data gathered from the DB. ("cinema" is a Dataset gloablly declared).
public short popolaModificaFilm(string titolo, ref TextBox txtAnno, ref TextBox txtCast, ref TextBox txtDurata, ref TextBox txtLocandina, ref TextBox txtRegista, ref TextBox txtTitolo, ref TextBox txtTrailer, ref TextBox txtTrama, ref ComboBox cmbGenere, ref ComboBox cmbNaz, ref CheckBox chkPellicola, ref CheckBox chkDigitale, ref CheckBox chk3d)
{
service.ricercaFilm(titolo).CopyToDataTable(cinema.film, LoadOption.PreserveChanges);
dsCinema.filmRow film = cinema.film[0];
txtAnno.Text = film["anno"].ToString().Trim();
txtCast.Text = film["cast"].ToString().Trim();
txtDurata.Text = film["durata"].ToString().Trim();
txtLocandina.Text = film["locandina"].ToString().Trim();
txtRegista.Text = film["regista"].ToString().Trim();
txtTitolo.Text = film["titolo"].ToString().Trim();
txtTrailer.Text = film["trailer"].ToString().Trim();
txtTrama.Text = film["trama"].ToString().Trim();
inserisciFilmCombo(ref cmbGenere,ref cmbNaz);
cmbGenere.SelectedValue = film["genere"];
cmbNaz.SelectedValue = film["nazionalita"];
if ((bool)film["pellicola"])
{
chkPellicola.Checked = true;
}
if ((bool)film["digitale"])
{
chkDigitale.Checked = true;
}
if ((bool)film["tridimensionale"])
{
chk3d.Checked = true;
}
return short.Parse(film["id"].ToString());
}
Through another button the user can update (in the dataset) the informations. This is the method:
public void aggiornaFilm(short id, string titolo, string regista, string cast, int anno, int durata, string trama, string trailer, string genere, string nazionalita, string locandina, bool pellicola, bool digitale, bool tridimensionale)
{
dsCinema.filmRow film = cinema.film.FindByid(id);
if (!titolo.Equals(""))
{ film["titolo"] = titolo; }
if (!regista.Equals(""))
{ film["regista"] = regista; }
if (!cast.Equals(""))
{ film["cast"] = cast; }
if (!trama.Equals(""))
{ film["trama"] = trama; }
if (!trailer.Equals(""))
{ film["trailer"] = trailer; }
if (!genere.Equals(""))
{ film["genere"] = genere; }
if (!locandina.Equals(""))
{ film["locandina"] = locandina; }
if (!anno.ToString().Equals(""))
{ film["anno"] = anno; }
if (!nazionalita.Equals(""))
{ film["nazionalita"] = nazionalita; }
if (!durata.ToString().Equals(""))
{ film["durata"] = durata; }
film["pellicola"] = pellicola;
film["digitale"] = digitale;
film["tridimensionale"] = tridimensionale;
}
When I try to use these functions Visul Studio spit the folowing exception:
System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="BusinessLogicalLayer"
I've noticed that the dataset (at the beginning of "aggiornaFilm") is empty (so obviously yhe find method returns null) despite I've injected data through "popolaModificaFilm". Both the method (aggiornaFilm & popolaModificaFilm) are in the same class and are called in the same form.
Tnx for any help, sorry for my poor english.