How to create SqlServer Views in ASP.Net C#,please forward few example programs.
how to use sqlserver views in asp.net C#?
HI
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Apr 18, 2013, 12:05 AM
hi,
SQL View is nothing but a virtual table whose contents are defined by sql query.
Example:
CREATE VIEW myEMPView
AS
SELECT e.EmpCode,u.userName FROM dbo.Users u
join employees e on e.empId = u.empId
you can use View in C# just as normal table.
DataTable t = new DataTable();
using (SqlConnection c = new SqlConnection(connectionstring))
{
c.Open();
using (SqlDataAdapter a = new SqlDataAdapter("SELECT * FROM myEMPView", c))
{
a.Fill(t);
}
}
hope this will help you.