Beginners help with Sql Select Statement.

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!!!!!!!!!

 Tel

0
terryt063
2/9/2009 8:24:18 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
383 Views

Similar Articles

[PageSpeed] 3

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.
(Donald Knuth)
0
Naom
2/9/2009 9:06:26 PM

 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

 Cheers!

 

Tel

0
terryt063
2/12/2009 7:25:51 AM
Reply: