• 大小: 56KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-17
  • 语言: C#
  • 标签: c#  sql  

资源简介

1.程序适合初学者,对c#以及sql数据库交互、控件使用方面有一定帮助; 2.适合上班族、学生党,对每一笔支出都有章可循!! 3.培养自己节俭的好习惯!!

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;


namespace Content
{
    class DataClass
    {
        
        public static SqlConnection com ;
        string sql = “Data Source=(local);Database=Content;User=sa;pwd=P@ssw0rd!2“;
      //  string sql_two = “Data Source=DESKTOP-P9U83GD;Database=db_Content_Two;User=sa;pwd=P@ssw0rd!2“;
        //实现数据库的打开
        public SqlConnection getcon()
        {
            com = new SqlConnection(sql);
            com.Open();
            return com;

        }

      
        //实现数据库的关闭
        public int con_close()
        {
            int n = 1;
            if (com.State == ConnectionState.Open)
            {
                com.Close();
                com.Dispose();//回收对象
                n = 0;
            }
            else
                n = 1;
            return n;
            
        }
        //实现对数据库表的填充
        public DataSet getDataSet(string SQLstr string tableName)
        {
            getcon();
            SqlDataAdapter SQLda = new SqlDataAdapter(SQLstr com);
            DataSet My_DataSet = new DataSet();
            SQLda.Fill(My_DataSet tableName);
            con_close();
            return My_DataSet;

        }
        //读取数据表的数据
        public SqlDataReader getread(string SQLstr)
        {
            getcon();
            SqlCommand SQLcom = new SqlCommand(SQLstr com);
            SQLcom.ExecuteNonQuery();
            SqlDataReader sqlread = SQLcom.ExecuteReader(CommandBehavior.CloseConnection);
            return sqlread;
        }
        //执行sql语句
        public void getsqlcom(string SQLstr)
        {
            getcon();
            SqlCommand SQLcom = new SqlCommand(SQLstr com);
            SQLcom.ExecuteNonQuery();
            SQLcom.Dispose();
            con_close();
        }
        //combox 的数据列绑定
        public void cbxBind(string M_str_sqlstr string M_str_table string M_str_tbMember ComboBox cbox)
        {
            DataSet myds = getDataSet(M_str_sqlstr M_str_table);
            cbox.DataSource = myds.Tables[M_str_table];
            cbox.DisplayMember = M_str_tbMember;//要显示的列

        }


    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        187  2019-06-02 23:17  Content\App.config

     文件      15360  2019-06-03 22:46  Content\bin\Debug\Content.exe

     文件        187  2019-06-02 23:17  Content\bin\Debug\Content.exe.config

     文件      36352  2019-06-03 22:46  Content\bin\Debug\Content.pdb

     文件      22984  2019-06-03 22:48  Content\bin\Debug\Content.vshost.exe

     文件        187  2019-06-02 23:17  Content\bin\Debug\Content.vshost.exe.config

     文件        490  2018-04-12 07:35  Content\bin\Debug\Content.vshost.exe.manifest

     文件       4137  2019-06-03 22:18  Content\Content.csproj

     文件       2465  2019-06-03 18:54  Content\DataClass.cs

     文件       2210  2019-06-03 22:27  Content\Form1.cs

     文件      11466  2019-06-03 22:18  Content\Form1.Designer.cs

     文件       5817  2019-06-03 22:18  Content\Form1.resx

     文件        716  2019-06-03 22:40  Content\Form2.cs

     文件       2403  2019-06-03 22:18  Content\Form2.Designer.cs

     文件       5817  2019-06-03 22:18  Content\Form2.resx

     文件        567  2019-06-03 22:48  Content\obj\Debug\Content.csproj.FileListAbsolute.txt

     文件       1033  2019-06-03 22:18  Content\obj\Debug\Content.csproj.GenerateResource.Cache

     文件       2209  2019-06-03 12:53  Content\obj\Debug\Content.csprojResolveAssemblyReference.cache

     文件      15360  2019-06-03 22:46  Content\obj\Debug\Content.exe

     文件        180  2019-06-03 22:18  Content\obj\Debug\Content.Form1.resources

     文件        180  2019-06-03 22:18  Content\obj\Debug\Content.Form2.resources

     文件      36352  2019-06-03 22:46  Content\obj\Debug\Content.pdb

     文件        180  2019-06-03 22:18  Content\obj\Debug\Content.Properties.Resources.resources

     文件        863  2019-06-02 23:17  Content\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6891  2019-06-03 22:14  Content\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2019-06-02 23:17  Content\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-06-02 23:17  Content\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-06-02 23:17  Content\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        519  2019-06-02 23:17  Content\Program.cs

     文件       1334  2019-06-02 23:17  Content\Properties\AssemblyInfo.cs

............此处省略14个文件信息

评论

共有 条评论