Untitled
unknown
csharp
4 years ago
2.1 kB
7
Indexable
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 MySQL_Deneme { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void txt_Baglan_Click(object sender, EventArgs e) { string _server = txt_Sunucu.Text; string _dbname = txt_Veritabani.Text; string _user = txt_Kullanici.Text; string _pass = txt_Sifre.Text; string MySQL_Baglanti = $"SERVER={_server};DATABASE={_dbname};UID={_user};PWD{_pass}"; if (string.IsNullOrEmpty(txt_Sunucu.Text) == true || string.IsNullOrEmpty(txt_Veritabani.Text) == true || string.IsNullOrEmpty(txt_Kullanici.Text) == true || string.IsNullOrEmpty(txt_Sifre.Text) == true) { MessageBox.Show("Bos Alanlari doldurunuz.","MySQL Deneme Programi ", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { using (var baglan = new MySqlConnection(MySQL_Baglanti)) { try { baglan.Open(); lbl_ConnectionInfo.Text = "BAĞLANTI KURULDU"; lbl_ConnectionInfo.ForeColor = Color.Green; } catch (Exception hataMsj) { MessageBox.Show("BAĞLANTI Sağlanamadı...Nedeni : \n" + hataMsj.ToString(), "HATA : " + hataMsj.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } private void Form1_Shown(object sender, EventArgs e) { txt_Sunucu.Focus(); } } }
Editor is loading...