winform优化过的登录退出代码
首先在VS中创建Windows窗体应用
在App.config中配置数据库连接地址
<connectionStrings>
<add name="connStr" connectionString="server=.;database=StudentNewDB;uid=sa;pwd=localhost;" providerName="System.Data.SqlClient" />
</connectionStrings>
创建一个SqlHelper.cs类
代码如下
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using Microsoft.IdentityModel.Protocols;
namespace WinStudent
{
public class SqlHelper
{
private static readonly string connString= ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
public static object ExecuteScalar(string sql