public partial class Form1 : Form
{
static string connectionString = "Data Source=LENOVO-PC;Initial Catalog=DicleY;Integrated Security=True";
public Form1()
{
InitializeComponent();
}
private static bool ConnectionTest(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
try
{
connection.Open();
return true;
}
catch (SqlException)
{
return false;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (ConnectionTest(connectionString))
{
MessageBox.Show("Connected");
}
else
MessageBox.Show("Not connected");
}
Yorumlar
Yorum Gönder