using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace bd_test_program
{
public partial class Form1 : Form
{
public static string constr = "server =31.31.196.8; user id =tytid; password =tytpass; persistsecurityinfo = True; port =3306; database =u0558875_default; SslMode = none";
public MySqlConnection conn = new MySqlConnection(constr);
public Form1()
{
InitializeComponent();
conn.Open();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void vxod(object sender, EventArgs e)
{
string login = textBox1.Text;
string password = textBox2.Text;
//string sql = "Select Name from Accounts WHERE Login = 'admin' AND Password='yaadmin'";
string sql = "Select Name from Accounts WHERE Login = '"+login+"' AND Password='"+password+"'";
MySqlCommand command = new MySqlCommand(sql, conn);
string name = command.ExecuteScalar().ToString();
MessageBox.Show(name);
Form2 fr2 = new Form2();
fr2.Show();
Hide();
}
}
}
ДОПОЛНИТЕЛЬНО: Ошибка появляется при создании второй формы, при работе с одной формой ошибки не возникает.