I am working on an accounting desktop application which gives many specific information about users.
The part that I am having trouble is here
date = comboBoxEdit2.EditValue.ToString();
line should not be assigned as null
as I did. But i could not find any better options and obviously, compiler gives me Object reference not set to an instance of an object.
error. I'm using devexpress and found only .EditValue control to check info from my database.
Thank you.
Here's my complete method,
public void fillCombo2()
{
using (SqlConnection con = new SqlConnection("Server=DLL;Database=BSSERVIS;User Id=sa;Password=1;"))
{
con.Open();
string date = ("select DATE from BSSERVIS.dbo.ENUMERATION");
date = comboBoxEdit2.EditValue.ToString();
System.Data.SqlClient.SqlDataReader dr = null;
SqlCommand cmd = new SqlCommand("select distinct(DATE) from BSSERVIS.dbo.ENUMERATION where WAREHOUSE_NR='" + date + "'");
dr = cmd.ExecuteReader();
dr.Read();
while (dr.Read())
{
string date = dr.GetString(0);
comboBoxEdit2.Properties.Items.Add(date);
}
}
}