La seguente routine mi permette di riempire delle textbox di una form per modificarle e salvarle con una update.
Il problema è che secondo il codice i campi che richiamo dal database sono vuoti, anzi se faccio il debug con visual studio.NET mi dice che sono vuoti...per esempio:
UserCode.Text = myRow["UserCode"].ToString(); dove ["UserCode"] risulta NULL e per questo mi si blocca la routine....
Per favore qualcuno mi dia una mano......!!!!!!
Posto il codice:
public void ChangePanel(object sender, EventArgs e)
{
SqlConnection myConn = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
myConn.Open();
detailPanel.Visible = false;
editPanel.Visible = true;
string strSQL = "SELECT * FROM tab_User WHERE ID=" + id;
SqlDataAdapter myAdapter = new SqlDataAdapter (strSQL, myConn);
DataTable msgDetails = new DataTable();
myAdapter.Fill (msgDetails);
DataRowView myRow = msgDetails.DefaultView[0];
UserCode.Text = myRow["UserCode"].ToString();
Name.Text = myRow["Name"].ToString();
Possible.Text = myRow["Possible"].ToString();
Address.Text = myRow["Address"].ToString();
Zip.Text = myRow["Zip"].ToString();
City.Text = myRow["City"].ToString();
CountryCode.Text = myRow["CountryCode"].ToString();
ISOCode.Text = myRow["ISOCode"].ToString();
State.Text = myRow["State"].ToString();
FiscalNumber.Text = myRow["FiscalNumber"].ToString();
VATNumber.Text = myRow["VATNumber"].ToString();
Phone.Text = myRow["Phone"].ToString();
Mobile.Text = myRow["Mobile"].ToString();
EMail.Text = myRow["EMail"].ToString();
Expanse.Text = myRow["Expanse"].ToString();
BankCode.Text = myRow["BankCode"].ToString();
CurrentAccount.Text = myRow["CurrenAccount"].ToString();
CreditCardCode.Text = myRow["CreditCardCode"].ToString();
ZoneCode.Text = myRow["ZoneCode"].ToString();
LanguageCode.Text = myRow["LanguageCode"].ToString();
ExpireDate.Text = myRow["ExpireDate"].ToString();
Note.Text = myRow["Note"].ToString();
editPanel.DataBind();
myConn.Close();
}
![]()