Advertisement
rakoczyn

[ASP.NET] SQL Data load

Aug 13th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. void LoadData()
  2.         {
  3.             string connStr = "Data Source=WOJTEK-LAPTOP\\SQLEXPRESS;Initial Catalog = TestDB;Integrated Security = true;";
  4.                        
  5.             using (var conn = new SqlConnection(connStr))
  6.             {
  7.                 SqlCommand cmd = new SqlCommand("SELECT * FROM Videos",conn);
  8.                 conn.Open();
  9.                 DataTable dt = new DataTable();
  10.                 dt.Load(cmd.ExecuteReader());
  11.                 GridView1.DataSource = dt;
  12.                 GridView1.DataBind();
  13.                 conn.Close();
  14.             }
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement