i have 3 text boxes for insert data into database but out of 3 text boxes only two textboxes to be used for insert data ,and 3 rd text box must be empty but in database it should shows null.
i wrote some code but display a error like syntax error near ','

VulpesRank #55 · 29.2K reputationPosted Oct 25, 2014, 4:30 AM EDT
INSERT INTO some_table (column1, column2, column3) VALUES (@tb1, @tb2, NULL)
where tb1 and tb2 are parameters whose values are (or are based on) textbox1 and textbox2 respectively.
Michal HabalcikRank #902 · 2.3K reputationPosted Oct 25, 2014, 7:11 AM EDT
If (String.IsNullOrEmpty(textbox.Text)) {
INSERT INTO some_table (column1, column2, column3) VALUES (@tb1, @tb2, NULL)
}
else
{
INSERT INTO some_table (column1, column2, column3) VALUES (@tb1, @tb2, textbox.Text)
}
or even a more simple version:
INSERT INTO some_table (column1, column2, column3) VALUES (@tb1, @tb2, String.IsNullOrEmpty(textbox.Text) ? NULL : textbox.Text)
Wim SturkenboomRank #2,527 · 554 reputationPosted Oct 25, 2014, 11:47 AM EDT
i wrote some code but display a error like syntax error near ','
[/quote]
show the relevant code and show the exact error message
And you probably need to use DBNull instead of null to achieve this from C#.