Connection property has not been initialized Hatasi
Bu hatanın sebebi, yazmış olduğumuz SqlCommand' in Connection özelliğinin set edilmemesidir.
Hatayı gidermek için aşağıdaki 2 yolu deneyebilirsiniz.
Birinci Yol : SqlCommand' in constructor' ından SqlConnection nesnesini vermek.
SqlConnection cnn = new SqlConnection("Server=.;Database=Northwind;uid=sa;pwd=1");
SqlCommand cmd = new SqlCommand("SELECT * FROM Employees", cnn);
İkinci Yol : SqlCommand' in Connection özelliğine SqlConnection nesnesini vermek.
SqlConnection cnn = new SqlConnection("Server=.;Database=Northwind;uid=sa;pwd=1");
SqlCommand cmd = new SqlCommand("SELECT * FROM Employees");
cmd.Connection = cnn;