Hi one and all. I apologise in advance for this question, I have searched and searched and have almost gone boss eyed looking at example after example that make no sense to me.
I've been tasked with sorting out effectively a SQL frontend. I got Visual Web Developer express and set about trying to learn "on the fly" but have come unstuck quickly!!!
The main crux of the headache is SQL Select statements.
The side pane of the site has a number of different "searches" avaliable to the user (radio button list). There is a standard search whereby it returns all from one table. Selecting something in the list appends the "WHERE ...." statement followed up by a text box to finish the query. The syntax and validity of the resultant SQL statement is fine, but I can't work out how to use it!!!!!!!!
On the main pane of that window there should be a grid view to show results. I have an SqlDataSource added and tied into the GridView but no matter what I try, I can't get the Sql string into the SqlDataSource select statement. It keeps telling me that I can't use a string. Unfortunately the system this is being developed on is not connected to the internet so I can't cut and paste code.
Any help or pointers would be greatly appreciated!!!!!!!!!
Did you try to set SQLDataSource.SelectCmd to your string and use GridView.DataBind() after that?
Beware of bugs in the above code; I have only proved it correct, not tried it.
In a way I feel like a bit of an idiot! After reading and re-reading the error, I worked out I'd biffed the fact that it's a string and should be enclosed in quotation marks.
In the end it was setting the SqlDataSource.SelectCommandType to text and then enclosing the string in quotes in SqlDataSource.SelectCommand