保存下的代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void toolStripButton1_Click(object sender, EventArgs e)
{
string insql = "INSERT INTO t_pzfl (time, pzh, zy, km, jfje, dfje, hjjf, hjdf, zd, sh, gz) VALUES (" + this.textBox1.Text + ",'" + this.textBox2.Text + "', " + this.textBox3.Text + "'" + this.textBox4.Text + "'" + this.textBox5.Text + "'" + this.textBox6.Text + "'" + this.textBox23.Text + "'" + this.textBox24.Text + "'" + this.textBox25.Text + "'" + this.textBox26.Text + "'" + this.textBox27.Text + "')";
SqlConnection con = new SqlConnection("server=.;database=caiwu;user id=sa;password=81719413");
con.Open();
SqlCommand com = new SqlCommand(insql, con );
SqlDataReader reader = com.ExecuteReader(); MessageBox.Show("保存成功!");
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void toolStripButton1_Click(object sender, EventArgs e)
{
string insql = "INSERT INTO t_pzfl (time, pzh, zy, km, jfje, dfje, hjjf, hjdf, zd, sh, gz) VALUES (" + this.textBox1.Text + ",'" + this.textBox2.Text + "', " + this.textBox3.Text + "'" + this.textBox4.Text + "'" + this.textBox5.Text + "'" + this.textBox6.Text + "'" + this.textBox23.Text + "'" + this.textBox24.Text + "'" + this.textBox25.Text + "'" + this.textBox26.Text + "'" + this.textBox27.Text + "')";
SqlConnection con = new SqlConnection("server=.;database=caiwu;user id=sa;password=81719413");
con.Open();
SqlCommand com = new SqlCommand(insql, con );
SqlDataReader reader = com.ExecuteReader(); MessageBox.Show("保存成功!");
}
}
}
解决方案 »
- 关于自定义button控件
- 程序点击关闭退出后,发现进程过10多秒之后才完全退出?
- Do not catch general exception types
- 菜鸟超人飞不了了,请求帮忙“选择”,谢谢
- 请教:winform关于组合框的高级用法
- ERROR: Unable to build shortcut named 'Shortcut to Primary output from 。。。。。。
- WPF怎么搞阿里云OSS云存储
- wpf 加载mapx组件
- 看了 Petshop 3.0 几个文件 , 如 DataProtector.cs , 信心一下子全没有了,太难懂了 , 高手 指点 !!! up 有分 ----
- 在线等待,寻求帮助!谢谢
- 急!c#读取ini文件的问题,取不出数据来!
- 页面参数获取问题
>>>改为
int num=com.ExecuteNonQuery();
SqlCommand com = new SqlCommand("", con);
com.ExecuteNonQuery();//执行sql
con.Close();
INSERT INTO t_pzfl (time, pzh) VALUES ('"+textBox1.Text +"','"+textBox2.Text +"');