• Visual中SqlHelper的书写


    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Data;
    6 using System.Data.SqlClient;
    7 using System.Configuration;

    插入引用

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

    用于获取链接字符串

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

    用于查询数据的方法

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

    用于增加新数据,删除数据,修改数据

  • 相关阅读:
    Validate US Telephone Numbers
    7月份总结
    Arguments Optional
    Everything Be True
    手机开发网页模板(20140124)
    整站开发初始化
    switch滑动开关
    js 面向对象
    Bootstrap 导航栏
    Bootstrap 标签页
  • 原文地址:https://www.cnblogs.com/douanan/p/13143678.html
Copyright © 2020-2023  润新知