using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
using System.Data;
using MySql.Data.MySqlClient;
namespace TestSQLite
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
private EditText etUsername, etPassword;
private Button btnInsert;
private TextView txtSysLog;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
etUsername = FindViewById<EditText>(Resource.Id.XetUsername);
etPassword = FindViewById<EditText>(Resource.Id.XetPassword);
btnInsert = FindViewById<Button>(Resource.Id.XbtnInsert);
txtSysLog = FindViewById<TextView>(Resource.Id.XtxtSysLog);
btnInsert.Click += BtnInsert_Click;
}
private void BtnInsert_Click(object sender, System.EventArgs e)
{
MySqlConnection con = new MySqlConnection("server = db4free.net; port = 3306; database = kronustest; user id = kronus; password = artem123; charset = utf8");
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
txtSysLog.Text = "Successfully connected";
}
}
catch (MySqlException ex)
{
txtSysLog.Text = ex.ToString();
}
finally
{
con.Close();
}
}
}
}