I'm implementing SqlDataSource in code behind. Here is my code:

var sqlDataSource = new SqlDataSource
                                {
                                    ConnectionString = _constr,
                                    SelectCommand =
                                        "SELECT One, Two FROM Foo WHERE (One = @One) AND (Two = @Two)"
                                };

How to declare parameters and attribute them values in code behind? I've tried to do something like this: sqlDataSource.SelectParameteres.Add("@One", "value"); etc. but it thrown execute scalar error.

share|improve this question
feedback

1 Answer

up vote 1 down vote accepted

try this

sqlDataSource.SelectParameters.Add(new Parameter("One", System.TypeCode.Int32, recordNo))
share|improve this answer
Thanks mate, it is working :) – Peter Sep 18 '11 at 8:07
youre welcome... – Royi Namir Sep 18 '11 at 8:08
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.