Parametric Sql

Jan 31, 2007

It is possible pass a parameter to a view????


es:


create view test

@var1
@var 2

select * from table 1
where column1 = @var1 and column2 = @var2
union all
select * from table 2
where column1 = @var1 and column2 = @var2
union all
..........



Thank's

View 4 Replies


ADVERTISEMENT

Parametric Sql Request

Oct 4, 2005

due to SQL Injection Attack I use parametric sql request like this   SqlConnection cnx = new SqlConnection(strCnx))        SqlParameter prm;        cnx.Open();        string strQry =             "SELECT Count(*) FROM Users WHERE UserName=@username ";        int intRecs;        SqlCommand cmd = new SqlCommand(strQry, cnx);        cmd.CommandType= CommandType.Text;        prm = new SqlParameter("@username",SqlDbType.VarChar,50);        prm.Direction=ParameterDirection.Input;        prm.Value = txtUser.Text;        cmd.Parameters.Add(prm);but how do I retrieve values ndlr, I have several rowsnormally its like SqlDataAdapter ...                        DataSet...                        DataTable...                        foreach (Datarow datarow in DataTable.Rows)                        {                           ......                        }so how do I retrieve values in parametric request ?????

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved