Note that there are some explanatory texts on larger screens.

plurals
  1. POConnection string property has not be initialized
    primarykey
    data
    text
    <p>When I add a Car in my application I get</p> <blockquote> <p>The ConnectionString property has not been initialized.</p> </blockquote> <p>I have the problem of ConnectionString property. I check similar question of mine but I found nothing helpfulness.</p> <p>I use a class connection named dbConnection.cs:</p> <pre><code>class dbConnection { //Connection to database private string con = "Data Source=(local)\\SQLEXPRESS; Initial Catalog=MLQ7024; Integrated Security=TRUE".ToString(); public string Con { get { return con; } } } </code></pre> <p>This is the code of my button </p> <pre><code>private void btnAddCar_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(dc.Con)) { DataTable dtCar = new DataTable(); BindingSource Car_bs = new BindingSource(); using (SqlCommand cmd = new SqlCommand("sp_Add_Car", con)) { try { cmd.CommandType = CommandType.StoredProcedure; //...... con.Open(); cmd.ExecuteNonQuery(); con.Close(); dtCar.Clear(); da.Fill(dtCar); } catch (Exception ex) { MessageBox.Show(ex.Message + "\t" + ex.Source); } } } refreshCar(); } </code></pre> <p>This is the code of an another button working well without error</p> <pre><code>private void btnAddPayment_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(dc.Con)) { DataTable dtPayment = new DataTable(); using (SqlCommand cmd = new SqlCommand("sp_Add_Paiements", con)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_paiement", SqlDbType.Char).Value = txtBoxPaymentId.Text; cmd.Parameters.Add("@montant", SqlDbType.SmallMoney).Value = txtBoxAmount.Text; cmd.Parameters.Add("@id_Location", SqlDbType.Char).Value = cmbpaymentLesaseId.Text; //cmd.Parameters.Add("@status", SqlDbType.Char).Value = txtBoxStatusPayment.Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); dtPayment.Clear(); da.Fill(dtPayment); btnAddLease.Hide(); refreshPayments(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\t" + ex.Source); } } } btnAddPayment.Hide(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload