I know Null
values can't be turned into string values so I looked all over the web and did find some answers like using IsDBNull()
but I can't seem to get it working. I'm new at this so please bear with me. I simply need the nullable field to be populated in the proper TextBox
as ""
when it's Null
. If you could give me a hand with the proper syntax it would be great. the field that may be Null
(or not) is projects_project_number
, I went back to my original code to show what I started with. Here it is:
ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["shopmanagerConnectionString1"];
MySqlConnection con = new MySqlConnection(conSettings.ToString());
string Query = "select * from shopmanager.quotes where idquotes = @search_quote_number;";
MySqlCommand cmdDataBase = new MySqlCommand(Query, con);
MySqlDataReader myReader;
try
{
con.Open();
cmdDataBase.Parameters.AddWithValue("@search_quote_number", search_quote_number.Text);
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sClient_number = myReader.GetString("client_info_client_number");
string sId = myReader.GetInt16("idquotes").ToString();
string sClientName = myReader.GetString("client_name");
string spredicted_start_date = myReader.GetString("predicted_start_date");
string sdate_required = myReader.GetString("requested_date");
string sdate_predicted = myReader.GetString("delivery_expected_date");
string sdate_received = myReader.GetString("date_received");
string squote_amount = myReader.GetString("quote_amount");
string sproject_number = myReader.GetString("projects_project_number");
quote_id.Text = sId;
client_name.Text = sClientName;
predicted_start_date.Text = spredicted_start_date;
date_required.Text = sdate_required;
date_predicted.Text = sdate_predicted;
date_received.Text = sdate_received;
quote_amount.Text = squote_amount;
project_number.Text = sproject_number;
temp_client_id.client_id = sClient_number;
search_quote_number.Text = "";
}
cmdDataBase.Parameters.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
con.Close();