Mam błąd : "Element „WindowsFormsApplication2.Form1.pictureBox6_Click_1(object, System.EventArgs)” to „metoda”, co jest nieprawidłowe w danym kontekście".
Gdzie leży mój błąd i co robię źle ?
PS: Proszę o wyrozumiałość bo jestem bardzo początkujący :)
private void pictureBox6_Click_1(object sender, EventArgs e)
{
SqlConnection dataConnection = new SqlConnection();
try
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = ".\\SQLEXPRESS";
builder.InitialCatalog = "baza";
builder.IntegratedSecurity = true;
dataConnection.ConnectionString = builder.ConnectionString;
dataConnection.Open();
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataCommand.CommandType = CommandType.Text;
dataCommand.CommandText = "SELECT [stan] FROM [XXX] WHERE [id] = 5";
object val = dataCommand.ExecuteScalar();
{
int wartosc = System.Convert.ToInt32(val);
switch (wartosc)
{
case 0:
pictureBox6_Click_1.Image = Image.FromFile(@"c:\szary.png"); break;
case 1:
pictureBox6_Click_1.Image = Image.FromFile(@"c:\zielony.png"); break;
case 2:
pictureBox6_Click_1.Image = Image.FromFile(@"c:\zielony.png"); break;
}
}
}
catch (SqlException a)
{
Console.WriteLine("Error accesing the database ", a.Message);
}