资源简介
c#窗体应用程序实现数据库增删改查c#窗体应用程序实现数据库增删改查c#窗体应用程序实现数据库增删改查

代码片段和文件信息
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 += “数钱“;
}
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(“请填写完整“);
}
}
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#编写串口通讯代码 多线程实现
相关资源
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
评论
共有 条评论