資源簡介
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個文件信息
- 上一篇:基于C#的Aforge類調用簡單_源碼
- 下一篇:C#庫存管理系統
評論
共有 條評論