K
Karen Hill
Suppose you have a textBox control. It is empty and you send the
this.textBox1.Text.ToString() value into a database. The control does
not send a NULL but instead a "".
What is the _CORRECT_ way (e.g. the way the C# language designers at MS
would do it) to handle this situation. I know you could just test for
a "" and then have code that would insert a NULL value like this:
if (this.textBox1.Text.ToString() == '')
{
//pseudo code ! I know you should use parameters!
insert into tableFOO(NULL);
}else
{
insert into tableFOO(this.textBox1.Text.ToString();
}
this.textBox1.Text.ToString() value into a database. The control does
not send a NULL but instead a "".
What is the _CORRECT_ way (e.g. the way the C# language designers at MS
would do it) to handle this situation. I know you could just test for
a "" and then have code that would insert a NULL value like this:
if (this.textBox1.Text.ToString() == '')
{
//pseudo code ! I know you should use parameters!
insert into tableFOO(NULL);
}else
{
insert into tableFOO(this.textBox1.Text.ToString();
}