DBexec.cs
资源名称:KTV.rar [点击查看]
上传用户:fzwcsgshou
上传日期:2022-07-30
资源大小:28414k
文件大小:2k
源码类别:
行业应用
开发平台:
Visual C++
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- namespace KTVData
- {
- class DBexec
- {
- public static bool exec(string command)
- {
- bool tag = false;
- SqlConnection conn = new SqlConnection(ConfigClass.configValue);
- SqlCommand cmd = new SqlCommand(command, conn);
- try
- {
- conn.Open();
- if (cmd.ExecuteNonQuery() > 0)
- {
- tag = true;
- }
- }
- catch
- {
- tag = false;
- }
- finally
- {
- cmd.Dispose();
- conn.Dispose();
- conn.Close();
- }
- return tag;
- }
- public static DataSet Select(string command)
- {
- SqlDataAdapter adpt = new SqlDataAdapter(command, ConfigClass.configValue);
- DataSet ds = new DataSet();
- adpt.Fill(ds);
- return ds;
- }
- public static int exec(string command, int i)
- {
- int tag = 0;
- SqlConnection conn = new SqlConnection(ConfigClass.configValue);
- SqlCommand cmd = new SqlCommand(command, conn);
- try
- {
- conn.Open();
- tag = cmd.ExecuteNonQuery();
- }
- catch
- {
- tag = -1;
- }
- finally
- {
- cmd.Dispose();
- conn.Dispose();
- conn.Close();
- }
- return tag;
- }
- }
- }