• 大小: 72KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-19
  • 语言: C#
  • 标签: C#  DataGridView  

资源简介

基于winform的分页查询技术,主要用的vs2013跟sql server 2008,效率挺高,需要的朋友可以下载,相互学习。

资源截图

代码片段和文件信息

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

namespace DataGridPages
{
    class clsDatabase : IDatabase
    {
        private string _strConn = “server =.;uid = sa;pwd = 123456;Initial Catalog= onecardonly;“;
        public string StrConn
        {
            get { return _strConn; }
            set { _strConn = value; }
        }

        private SqlConnection connection;
        public int tt;

        public SqlConnection GetDBConnection()
        {
            SqlConnection _conn = new SqlConnection(_strConn);
            return _conn;
        }

        public bool IsDataExisted(string strCmd)
        {
            bool bRet = false;
            connection = GetDBConnection();

            try
            {
                if (connection.State == ConnectionState.Closed)
                    connection.Open();

                SqlCommand cmd = new SqlCommand(strCmd connection);
                object obj = cmd.ExecuteScalar();
                bRet = obj == null ? false : true;

                connection.Close();
                return bRet;
            }
            catch (ApplicationException ex)
            {
                connection.Close();
                throw ex;
            }
        }

        public bool ExecuteSQLCMD(string strCmd)
        {
            connection = GetDBConnection();
            bool bRet = false;
            try
            {
                if (connection.State == ConnectionState.Closed)
                    connection.Open();

                SqlCommand cmd = new SqlCommand(strCmd connection);
                int? iResult = cmd.ExecuteNonQuery();
                bRet = iResult == null ? false : true;

                connection.Close();
                return bRet;
            }
            catch (ApplicationException ex)
            {
                connection.Close();
                throw ex;
            }
        }

        public int DataResult(string strCmd)
        {
            int Ret = 0;
            connection = GetDBConnection();

            try
            {
                if (connection.State == ConnectionState.Closed)
                    connection.Open();

                SqlCommand cmd = new SqlCommand(strCmd connection);
                object obj = cmd.ExecuteScalar();
                Ret = obj == null ? 0 : Convert.ToInt32(obj);

                connection.Close();
                return Ret;
            }
            catch (ApplicationException ex)
            {
                connection.Close();
                throw ex;
            }
        }

        public DataSet GetDataFromDB(string strCmd)
        {
            DataSet ds = new DataSet();
            SqlConnection conn = GetDBConnection();
            SqlCommand cmd = new SqlCommand(strCmd conn);
            SqlDataAdapter adt = new

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-09-13 09:09  DataGridPages\
     目录           0  2014-09-27 20:02  DataGridPages\DataGridPages\
     文件         881  2014-09-12 19:53  DataGridPages\DataGridPages.sln
     文件       20992  2014-09-12 21:18  DataGridPages\DataGridPages.suo
     文件       52736  2014-09-27 20:15  DataGridPages\DataGridPages.v12.suo
     目录           0  2014-09-12 19:54  DataGridPages\DataGridPages\bin\
     目录           0  2014-09-13 09:10  DataGridPages\DataGridPages\bin\Debug\
     文件       17408  2014-09-13 22:15  DataGridPages\DataGridPages\bin\Debug\DataGridPages.exe
     文件       42496  2014-09-13 22:15  DataGridPages\DataGridPages\bin\Debug\DataGridPages.pdb
     文件       24224  2014-09-27 19:48  DataGridPages\DataGridPages\bin\Debug\DataGridPages.vshost.exe
     文件         490  2010-03-17 22:39  DataGridPages\DataGridPages\bin\Debug\DataGridPages.vshost.exe.manifest
     目录           0  2014-09-12 19:54  DataGridPages\DataGridPages\bin\Release\
     文件        3898  2014-09-27 20:02  DataGridPages\DataGridPages\clsDatabase.cs
     文件        2770  2014-09-13 12:08  DataGridPages\DataGridPages\clsDataGridView.cs
     文件         962  2014-09-13 17:30  DataGridPages\DataGridPages\clsRecord.cs
     文件        3863  2014-09-13 12:11  DataGridPages\DataGridPages\DataGridPages.csproj
     文件        3374  2014-09-27 20:02  DataGridPages\DataGridPages\FrmMain.cs
     文件        6844  2014-09-13 17:52  DataGridPages\DataGridPages\FrmMain.Designer.cs
     文件        5817  2014-09-13 17:52  DataGridPages\DataGridPages\FrmMain.resx
     文件         410  2014-09-27 19:49  DataGridPages\DataGridPages\IDatabase.cs
     目录           0  2014-09-12 19:52  DataGridPages\DataGridPages\obj\
     目录           0  2014-09-12 19:52  DataGridPages\DataGridPages\obj\x86\
     目录           0  2014-09-27 20:01  DataGridPages\DataGridPages\obj\x86\Debug\
     文件         788  2014-09-27 20:01  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.csproj.FileListAbsolute.txt
     文件         979  2014-09-13 17:53  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.csproj.GenerateResource.Cache
     文件        9180  2014-09-13 10:04  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.csprojResolveAssemblyReference.cache
     文件       17408  2014-09-13 22:15  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.exe
     文件         180  2014-09-13 17:53  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.FrmMain.resources
     文件         180  2014-09-13 12:11  DataGridPages\DataGridPages\obj\x86\Debug\DataGridPages.Properties.Resources.resources
     文件        2873  2014-09-13 10:08  DataGridPages\DataGridPages\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7068  2014-09-13 12:07  DataGridPages\DataGridPages\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此处省略8个文件信息

评论

共有 条评论