Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

1 Answer 1

up vote 3 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

Your Answer

 
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.