惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 空军

过多边形边上某点的任意直线等分面积 VisualAPL Installer for Visual Studio 2008 [ZT] Create a Microsoft Access Database Using ADOX and Visual Basic .NET 数的分解,据说是清华的一道复试上机题 为System.Windows.Forms.FontDialog类添加Location属性 f(f(x)) = -x [zt]〖Math〗构造函数使得任意小的区间所对应的值域都是整个实数域 [zt]鸟巢、水立方:同一个地方,同一梦想 〖Math〗据传,任意锐角等于0° 爱因斯坦的超级问题(谁养鱼)SQL解法 “槑囧圐圙”您认得这些汉字吗? 根据URL提取页面的Title,根据网页的charset自动判断Encoding MSDN“MidpointRounding 枚举”中文翻译有误 C# 2.0 新特性(泛型、可空类型)应用一例 表达式计算器 Google速记 Google中国编程挑战赛第一轮 Google中国编程挑战赛资格赛 数学家
数据库访问模块
空军 · 2005-10-15 · via 博客园 - 空军

 1namespace Skyiv.Data.SqlClient
 2{
 3  using System.Data;
 4  using System.Data.SqlClient;
 5
 6  class SqlObject
 7  {
 8    protected SqlConnection conn;
 9
10    // 构造函数,参数为连接串。
11    protected SqlObject(string strConn)
12    {
13      conn = new SqlConnection(strConn);
14    }

15
16    // 执行SQL,将结果返回到数据集中。
17    public DataSet DsQuery(string strSql, params SqlParameter [] paras)
18    {
19      SqlCommand cmd = new SqlCommand(strSql, conn);
20      foreach (SqlParameter para in paras)
21      {
22        cmd.Parameters.Add(para);
23      }

24      SqlDataAdapter apt = new SqlDataAdapter(cmd);
25      DataSet ds = new DataSet();
26      apt.Fill(ds);
27      return ds;
28    }

29
30    // 执行SQL,将结果返回到数据表中。
31    public DataTable DtQuery(string strSql, params SqlParameter [] paras)
32    {
33      return DsQuery(strSql, paras).Tables[0];
34    }

35
36    // 执行SQL,将结果返回到数据行中。
37    public DataRow DrQuery(string strSql, params SqlParameter [] paras)
38    {
39      DataTable dt = DsQuery(strSql, paras).Tables[0];
40      if (dt.Rows.Count == 0return null;
41      else return dt.Rows[0];
42    }

43
44    // 执行SQL,并返回查询所返回的结果集中第一行的第一列。
45    public object ScalarQuery(string strSql, params SqlParameter [] paras)
46    {
47      SqlCommand cmd = new SqlCommand(strSql, conn);
48      try
49      {
50        cmd.Connection.Open();
51        foreach (SqlParameter para in paras)
52        {
53          cmd.Parameters.Add(para);
54        }

55        return cmd.ExecuteScalar();
56      }

57      finally
58      {
59        cmd.Connection.Close();
60      }

61    }

62
63    // 执行SQL,返回受影响的行数。
64    public int ExecNonQuery(string strSql, params SqlParameter [] paras)
65    {
66      SqlCommand cmd = new SqlCommand(strSql, conn);
67      cmd.Connection.Open();
68      foreach (SqlParameter para in paras)
69      {
70        cmd.Parameters.Add(para);
71      }

72      int n = cmd.ExecuteNonQuery();
73      cmd.Connection.Close();
74      return n;
75    }

76
77    // 执行SQLs,返回受影响的行数。
78    public int ExecNonQuerys(params string [] strSqls)
79    {
80      SqlCommand cmd = new SqlCommand();
81      cmd.Connection = conn;
82      cmd.Connection.Open();
83      int n = 0;
84      foreach (string strSql in strSqls)
85      {
86        cmd.CommandText = strSql;
87        n += cmd.ExecuteNonQuery();
88      }

89      cmd.Connection.Close();
90      return n;
91    }

92
93  }
 // End of class SqlObject
94}
   // End of namespace Skyiv.Data.Sql