简体   繁体   中英

Application freeze at connection.open()

I created a Firebird database and successfully connected to it via Visual Studio Server Explorer. Now I want to test it through code, so I made a simple form that - on a button press - changes a label text to a value from the database. Here is the code

private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("data source=localhost;initial catalog=D:\\poslovanje\\POSLOVANJE.FDB;user id=SYSDBA");
            SqlCommand cmd = new SqlCommand("SELECT ID FROM USERS", con);

            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while(dr.Read())
            {
                label3.Text = dr[0].ToString();
            }
            con.Close();
        }

Problem is my application just freezes when it comes to con.Open();

I have also tried this connection string:

User=SYSDBA;Password=masterkey;Database=D:\\poslovanje\\poslovanje.fdb;Data Source=localhost;

这是基本的初学者错误,我需要使用FbConnection和FbCommand,而不是Sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM