Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Using a Views in .net and c#

using (SqlConnection connection = new SqlConnection("Data Source=ravensqlexpress;Initial Catalog=ucs;Integrated Security=True;Pooling=False"))
{
    using (SqlCommand command = connection.CreateCommand())
    {
        command.CommandText = "SELECT * from your_view WHERE your_where_clause";

        connection.Open();
        using (SqlDataReader reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                // process result
                reader.GetInt32(0); // get first column from view, assume it's a 32-bit int
                reader.GetString(1); // get second column from view, assume it's a string
                // etc.
            }
        }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Using #Views
ADD COMMENT
Topic
Name
1+6 =