C#公共类中常用方法总结(共4页).docx





《C#公共类中常用方法总结(共4页).docx》由会员分享,可在线阅读,更多相关《C#公共类中常用方法总结(共4页).docx(4页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上using System;using System.Collections.Generic;using System.Linq;using System.Text;using MrCy.BaseClass;using System.Data.SqlClient;using System.Windows.Forms;using System.Data;namespace MrCy.BaseClass class DBOperate SqlConnection conn = DBconn.Connection(); / / 主要用于对数据库中的数据表信息执行增、删、改的操
2、作 / / / public int OperateData(string sqlStr) conn.Open();/打开数据库连接 SqlCommand cmd = new SqlCommand(sqlStr, conn);/创建命令对象 int n = (int)cmd.ExecuteNonQuery();/执行SQL命令,得到受影响的行数 conn.Close();/关闭数据库连接 return n;/返回受影响的行数 / / 用于将数据库中的数据绑定到DataGridView控件上 / / / public void GetDt(DataGridView dgv, string sql
3、) SqlDataAdapter sda = new SqlDataAdapter(sql, conn);/创建数据适配器对象 DataSet ds = new DataSet();/创建数据集对象 sda.Fill(ds);/填充数据集 dgv.DataSource = ds.Tables0;/设置DataGridView所显示的数据源 ds.Dispose();/释放资源 / / 用于对指定的ComboBox控件进行数据绑定 / / / / public void bindComboBox(ComboBox cbb, string strTable, int n) string str =
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 公共 常用 方法 总结

限制150内