Witam
Dopiero zaczynam swoją przygodę z C# więc prosze o wyrozumiałość (dotychczas pisałem tylko w Delphi).
Próbuje połączyć się w aplikacji z serwerem MySql.
Zgodnie z tym co wyczytałem w necie dodałem do projektu
using MySql.Data.MySqlClient;
(kopiując również bibliotekę) oraz wklepałem coś takiego:
private void Initialize()
{
connectionString = "SERVER=sqlair.dhosting.pl; DataBase=nawa_bazy; UserId=uzytkownik; PWD=haslo";
connection = new MySqlConnection(connectionString);
}
private bool OpenConnection()
{
try
{
connection.Open();
return true;
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show("Cannot connect to server. Contact administrator");
break;
case 1045:
MessageBox.Show("Invalid username/password, please try again");
break;
}
return false;
}
}
Jednak program nie kompiluje się, wywala za to błędy:
Error 1 The name 'connectionString' does not exist in the current context c:\users\tomasz filipek\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form3.cs 28 13 WindowsFormsApplication1
Error 2 The name 'connection' does not exist in the current context c:\users\tomasz filipek\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form3.cs 29 13 WindowsFormsApplication1
Error 3 The name 'connectionString' does not exist in the current context c:\users\tomasz filipek\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form3.cs 29 46 WindowsFormsApplication1
Error 4 The name 'connection' does not exist in the current context c:\users\tomasz filipek\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form3.cs 36 16 WindowsFormsApplication1
Możecie mi powiedzieć co zrobiłem nie tak ?