string dbconnection = (@"Data Source=EMIII-PC;Initial Catalog=gymdatabase;Integrated Security=True"); public void BindMyData() { SqlConnection conn = new SqlConnection(dbconnection); try { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Student", conn); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); myDataGrid.ItemsSource = ds.Tables[0].DefaultView; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { conn.Close(); } } private void Window_Loaded(object sender, RoutedEventArgs e) { BindMyData(); }
SELECT Col1, Col2 FROM Student
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)