1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

WPF Form freezing up

Discussão em 'StackOverflow' iniciado por fdantas, Agosto 10, 2017.

  1. fdantas

    fdantas Administrator Moderador

    Ok - I have finally got my connection string and sql string correct in this WPF form. I kept getting reader exceptions until I finally got the sql string the correct way, so since I am not getting errors now - I am assuming it is correct. Have inserted a breakpoint at IDbCommand and stepped through, and all steps seem to go fine. But the program locks up and does not display any data in the datagrid. Cannot even click on the form once all statements are processed. What have I missed here? This is a Progress OpenEdge DB - and this is the recommended connection and command from Progress.

    private void MonReadButton_Click(object sender, RoutedEventArgs e)
    {

    var estNum = EstTextBox.Text;
    {
    string connectString = "DSN=****;uid=**;pwd=*****;host=****;port=****;db=****;";
    using (OdbcConnection dbConn = new OdbcConnection(connectString))
    {
    try
    {
    dbConn.Open();

    }
    catch (Exception)
    {
    MessageBox.Show("connection failed");
    }





    IDbCommand dbcmd = dbConn.CreateCommand();
    string sqlstr = @"SELECT ""Estimate"".""Labor-Cost"" FROM ""GAMS1"".""PUB"".""Estimate"" WHERE ""Estimate"".""Estimate-ID""=" + estNum;

    dbcmd.CommandText = sqlstr;
    IDataReader reader = dbcmd.ExecuteReader();
    while (reader.Read())
    {
    DataTable dt = new DataTable();
    dt.Load(reader);
    DataGrid1.ItemsSource = dt.DefaultView;
    }
    reader.Close();
    reader = null;
    dbcmd.Dispose();
    dbcmd = null;
    dbConn.Close();

    }

    }
    }

    Continue reading...

Compartilhe esta Página