using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Salutations
{
public partial class Form1 : Form
{
private const string connect = "Data Source=MSI\\SQLEXPRESS;Initial Catalog=Howdy;Integrated Security=True";
public Form1()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
string name = txtUser.Text;
string pass = txtPass.Text;
try
{
using (SqlConnection conn = new SqlConnection(connect))
{
conn.Open();
string sql = "SELECT * FROM hithere WHERE userName = @name AND passWord = @pass ";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@pass", pass);
SqlDataReader render = cmd.ExecuteReader();
if (render.HasRows)
{
MessageBox.Show("lOGIN SUSSECCFUL");
}
else
{
MessageBox.Show("LOGIN FAILSE");
}
}
}catch(Exception ex)
{
MessageBox.Show("Connect failse", ex.Message);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult thongbao;
thongbao = (MessageBox.Show("Do you want exit? ", "thongbao", MessageBoxButtons.YesNo, MessageBoxIcon.Warning));
if(thongbao == DialogResult.Yes)
{
Application.Exit();
}
}
}
}
En esta página del sitio puede ver el video en línea Csharp connect to SQL Server de Duración hora minuto segunda en buena calidad , que subió el usuario HUY HOÀNG 06 julio 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 613 veces y le gustó 0 a los espectadores. Disfruta viendo!