Writing sqlhelper in visual

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Data;
 using System.Data.SqlClient;
 using System.Configuration;

insert reference

  public static string strconn = ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;

Used to get the link string

public static DataTable Cha(string sql)
            DataTable table = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(sql, strconn);
            return table;

Methods for querying data

public static int ZSG(string sql)
            int num = 0;
            SqlConnection conn = new SqlConnection(strconn);
            SqlCommand cmd = new SqlCommand(sql, conn);
            num = cmd.ExecuteNonQuery();
            if (conn.State == ConnectionState.Open)
            return num;

It is used to add new data, delete data and modify data