I have the following code:
OpeningForm of = new OpeningForm();
of.ShowDialog();
SqlConnection SqlBaglanti = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MolaTakip; integrated security=true");
SqlBaglanti.Open();
SqlCommand komut = new SqlCommand("AgentBilgisiDondur')", SqlBaglanti);
komut.CommandType = System.Data.CommandType.StoredProcedure;
komut.Parameters.AddWithValue("@LoginName", ThisAgent.LoginName);
SqlDataReader dr = komut.ExecuteReader();
while (dr.Read())
{
ThisAgent.AgentID = int.Parse(dr["UserID"].ToString());
ThisAgent.AgentAdi = dr["UserName"].ToString();
}
SqlBaglanti.Close();
FileStream fs = new FileStream(@"C:\agent.bin", FileMode.OpenOrCreate);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, ThisAgent);
All of this codes written in the Form_Load
event. But form loads at
SqlDataReader dr = komut.ExecuteReader();
line, further commands are not running.