I want to have null values in my table when the user has left the textbox empty. I'm doing this with a array and a for loop:
private void AddQuestion()
{
    string [] checkinput= new string[] { txtBxQuestionCat.Text, txBxQuestion.Text }; 
    string[] countinput= new string[2]; 
    if (String.IsNullOrEmpty(txtBxQuestionCat.Text) && String.IsNullOrEmpty(txBxQuestion.Text))
    {   
        ExceptiesException ex = new ExceptiesException("error");
        throw ex;
    }
    for (int i = 0; i < countinput.Length; i++) 
    {
        if (checkinput[i] == "") 
        {
            countinput[i] = null; 
        }
    }
    try
    {   
        qa = new HR5DataSetTableAdapters.QueriesTableAdapter();
        qa.AddQuestion(countinput[0], countinput[1]);
        hR5DataSetQuestionTableAdapter.Fill(hR5DataSet.question);
        questionViewSource1.View.MoveCurrentToLast();
        MessageBox.Show("add complete");
    }
    catch (SqlException ex) 
    {
        MessageBox.Show(ex.Message); 
    }
}
This should be working, but when I'm adding a questioncat and a question and load it into my datagrid, the new questioncat and question has not added to the database, only a new QuestionId. I think it is because I say countinput[i] = null, but I don't know how I could also say that the values need to be null if de textboxes are empty.
 
     
    