SQL IS NULL logic error
I'm new to this forum so I'm not sure if it's good to post twice about the same questions but seems like the last question sort of died out and i kind of have a new question, so here it is
I wanted my program so that if the combo box was empty, it would mean to select all (or even imagine it to ignore WHERE
clause to start out with). the answer that i found throughout the net was to use param = @param OR @param IS NULL
. however, when i do that and i want to display my data, it only shows the column row names (meaning it got the right table) but no data. I'm not sure why, from what i read this method is sort of like an if statement. here's my code i simplified it jut for this problem
da.SelectCommand = new OleDbCommand("SELECT * FROM TestQuery WHERE CustomerName = @CustomerName 开发者_如何学JAVAOR @CustomerName IS NULL)", cs);
da.SelectCommand.Parameters.Add("@CustomerName", OleDbType.VarChar).Value = combo_CustomerView.Text.ToString();
da = data adapter. i'm using visual studio 2010 and ado.net with oledb (access). this works when I have info on the customer but when theres none, well the problem is described above. any sorta help will be helpful... thanks
精彩评论