Question

I am trying to build a very simple WPF Application using C# on .Net F/W 4.0. When i click a button, i wanted it to run a sql query(stored in "finalupdatedsql1" variable) against oracle database. I want the results on a Datagrid. For some reason Datagrid.DataSource property is not recognized. Could anyone help me with an alternate approach or correct my code? FYI, I am using ODP.Net and Oracle connection tests fine. Thanks.

private void RunSQL_Click(object sender, RoutedEventArgs e)
    {
        cmd = new OracleCommand(finalupdatedsql1, conn);//finalupdatedsql1 has the sqlquery in string representation.
        cmd.CommandType = CommandType.Text;
        da = new OracleDataAdapter(cmd);
        cb = new OracleCommandBuilder(da);
        ds = new DataSet();
        da.Fill(ds);
        MyDataGrid.DataSource = ds.Tables[0];//DataSource not showing up in intellisense or recognizing


        conn.Close();
        conn.Dispose();
    }
Was it helpful?

Solution

You're looking for ItemsSource:

MyDataGrid.ItemsSource = ds.Tables[0];

The DataSource property would be a Windows Forms application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top