This ultra simple code doesn't work... It gives me the
System.NullReferenceException: 'Object reference not set to an instance of an object.'
I tried to recreate the form and the entire program, but it has not changed anything, and it's pretty much the only thing that's written in the class
private void combo_LastName_TextChanged(object sender, EventArgs e)
{
WhereQ[0] = "LASTNAME = '" + combo_LastName.Text + "'";
combo_FirstName.DisplayMember = "FIRSTNAME";
combo_FirstName.DataSource = InTable_Employee.Select(WhereQ[0]);
}
Rest of the code:
private string[] WhereQ;
private readonly string InDBConn_Locl = Settings.Default.DBConn_LOCL;
private DataSet InDB = new();
private DataTable InTable_Employee = new();
public SelectUser()
{
InitializeComponent();
}
private void SelectUser_Load(object sender, EventArgs e)
{
CreateTable(InDBConn_Locl, "SELECT DISTINCT LASTNAME, FIRSTNAME, GID FROM EMPLOYEE", "EMPLOYEE");
InTable_Employee = InDB.Tables["EMPLOYEE"];
combo_LastName.DisplayMember = "LASTNAME";
combo_LastName.DataSource = InTable_Employee;
combo_GID.DisplayMember = "GID";
combo_GID.DataSource = InTable_Employee;
}
private void CreateTable(string TableName, string Conn, string Query)
{
DataTable InTable = API.SQL_Read(TableName, Conn, Query);
InTable.Rows.InsertAt(InTable.NewRow(), 0);
InDB.Tables.Add(InTable);
}