資源簡介
c#窗體應用程序?qū)崿F(xiàn)數(shù)據(jù)庫增刪改查c#窗體應用程序?qū)崿F(xiàn)數(shù)據(jù)庫增刪改查c#窗體應用程序?qū)崿F(xiàn)數(shù)據(jù)庫增刪改查

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Data.SqlClient;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?CDemo1
{
????public?partial?class?frmadd?:?Form
????{
????????public?frmadd()
????????{
????????????InitializeComponent();
????????}
????????private?void?frmadd_Load(object?sender?EventArgs?e)
????????{
????????????//this.
????????????this.rdonan.Checked?=?this.rdos1.Checked?=?true;
????????????this.cboxueli.SelectedIndex?=?0;
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????if?(txtid.Text?!=?““?&&?txtname.Text?!=?““)
????????????{
????????????????string?id?=?txtid.Text;
????????????????string?name?=?this.txtname.Text;
????????????????string?sex?=?“男“;
????????????????if?(rdonv.Checked?==?true)?{
????????????????????sex?=?“女“;
????????????????}
????????????????DateTime?chus?=?DateTime.Parse(dtpcs.Text);
????????????????string?nianji?=?“S1“;
????????????????if?(rdos2.Checked?==?true)?{
????????????????????nianji?=?“S2“;
????????????????}?else?if?(rdoy2.Checked?==?true)?{
????????????????????nianji?=?“Y2“;
????????????????}
????????????????string?xueli?=?cboxueli.Text;
????????????????string?aihao?=?““;
????????????????if?(ckchifan.Checked?==?true)?{
????????????????????aihao?+=?“吃飯?“;
????????????????}
????????????????if?(ckshuijiao.Checked?==?true)?{
????????????????????aihao?+=?“睡覺“;
????????????????}
????????????????if?(ckshuqian.Checked?==?true)?{
????????????????????aihao?+=?“數(shù)錢“;
????????????????}
????????????????string?str?=?“server=.;database=SchoolManager;uid=sa;pwd=root“;
????????????????SqlConnection?con?=?new?SqlConnection(str);
????????????????try
????????????????{
????????????????????string?sql?=?string.Format(@“insert?into?dbo.Student
values(‘{0}‘‘{1}‘‘{2}‘‘{3}‘‘{4}‘‘{5}‘‘{6}‘)“?id?name?sex?chus?xueli?nianji?aihao);
????????????????????SqlCommand?cmd?=?new?SqlCommand(sql?con);
????????????????????con.Open();
????????????????????int?addfh?=?cmd.ExecuteNonQuery();
????????????????????if?(addfh?>?0)
????????????????????{
????????????????????????MessageBox.Show(“添加成功“);
????????????????????}
????????????????????else?{
????????????????????????MessageBox.Show(“添加失敗“);
????????????????????}
????????????????}
????????????????catch?(Exception)
????????????????{
????????????????????throw;
????????????????}
????????????????finally?{
????????????????????con.Close();
????????????????}
????????????}
????????????else?{
????????????????MessageBox.Show(“請?zhí)顚懲暾埃?
????????????}
????????}
????????private?void?btnquery_Click(object?sender?EventArgs?e)
????????{
????????????if?(txtid.Text?!=?““)
????????????{
????????????????string?id?=?txtid.Text;
????????????????string?str?=?“server=.;database=SchoolManager;uid=sa;pwd=root“;
????????????????SqlCo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-21?17:01??CDemo\
?????目錄???????????0??2018-07-21?09:49??CDemo\.vs\
?????目錄???????????0??2018-07-21?09:49??CDemo\.vs\CDemo\
?????目錄???????????0??2018-07-21?09:49??CDemo\.vs\CDemo\v14\
?????文件???????48128??2018-07-21?17:02??CDemo\.vs\CDemo\v14\.suo
?????文件?????????985??2018-07-21?11:18??CDemo\CDemo.sln
?????目錄???????????0??2018-07-21?17:01??CDemo\CDemo1\
?????文件?????????189??2018-07-21?09:48??CDemo\CDemo1\App.config
?????目錄???????????0??2018-07-21?09:51??CDemo\CDemo1\bin\
?????目錄???????????0??2018-07-21?09:52??CDemo\CDemo1\bin\Debug\
?????文件??????176640??2018-07-21?16:56??CDemo\CDemo1\bin\Debug\CDemo1.exe
?????文件?????????189??2018-07-21?09:48??CDemo\CDemo1\bin\Debug\CDemo1.exe.config
?????文件???????42496??2018-07-21?16:56??CDemo\CDemo1\bin\Debug\CDemo1.pdb
?????文件???????22696??2018-07-21?17:01??CDemo\CDemo1\bin\Debug\CDemo1.vshost.exe
?????文件?????????189??2018-07-21?09:48??CDemo\CDemo1\bin\Debug\CDemo1.vshost.exe.config
?????目錄???????????0??2018-07-21?09:51??CDemo\CDemo1\bin\Release\
?????文件????????4543??2018-07-21?12:13??CDemo\CDemo1\CDemo1.csproj
?????文件????????7135??2018-07-21?17:01??CDemo\CDemo1\frmadd.cs
?????文件???????15213??2018-07-21?16:50??CDemo\CDemo1\frmadd.Designer.cs
?????文件????????5817??2018-07-21?16:50??CDemo\CDemo1\frmadd.resx
?????文件????????2135??2018-07-21?12:02??CDemo\CDemo1\frmLogin.cs
?????文件????????6286??2018-07-21?11:51??CDemo\CDemo1\frmLogin.Designer.cs
?????文件??????230638??2018-07-21?11:51??CDemo\CDemo1\frmLogin.resx
?????文件????????7810??2018-07-21?16:56??CDemo\CDemo1\frmset.cs
?????文件???????16056??2018-07-21?16:56??CDemo\CDemo1\frmset.Designer.cs
?????文件????????6011??2018-07-21?16:56??CDemo\CDemo1\frmset.resx
?????目錄???????????0??2018-07-21?09:48??CDemo\CDemo1\obj\
?????目錄???????????0??2018-07-21?16:56??CDemo\CDemo1\obj\Debug\
?????文件?????????640??2018-07-21?17:01??CDemo\CDemo1\obj\Debug\CDemo1.csproj.FileListAbsolute.txt
?????文件????????1097??2018-07-21?16:56??CDemo\CDemo1\obj\Debug\CDemo1.csproj.GenerateResource.Cache
?????文件????????2384??2018-07-21?09:52??CDemo\CDemo1\obj\Debug\CDemo1.csprojResolveAssemblyReference.cache
............此處省略19個文件信息
- 上一篇:自己 C#寫的OPC客戶端
- 下一篇:c#編寫串口通訊代碼 多線程實現(xiàn)
評論
共有 條評論