想问下我用的是windowsform做的一个学生信息系统管理界面其中有添加查询和删除更新几个按钮..想求教这几个按钮的代码该如何写..刚学与数据库交互使用还不是太熟练...
解决方案 »
- 怎么在C#2005下向水晶报表传递参数
- 发送传真问题?
- 在C#中怎样使用DATASET来创建ACCESS表?
- 高手给看看,ADO.NET的问题,诚心学习!80分相送!
- 本人刚转向C#,对这一句“bnCtoF.Click += new EventHandler(this.bnCtoF_Click);”不理解,请高手讲讲。
- c#与Access的报表
- 用GDI+做得自定义实时显示数据控件叠加时的效率问题
- 请各位带星星的高手来看看啊, 关于Ado.Net的问题.
- 如何在C#中实现数据库备份
- 请问用C#怎样创建数据库??
- 看看这个排序问题如何解决。
- radiobottonlist数据库正常绑定,SelectValue值竟然取的是null,帮看下代码谢谢
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
string txt1 = this.textBox1.Text ;
string txt2 = this.textBox2.Text;
string txt3 = this.textBox3.Text;
SqlConnection con = new SqlConnection("Data Source=FZ-53\\SQL2005;Initial Catalog=ACCP;Integrated Security=True");
con.Open();
MessageBox.Show("数据库连接成功!");
SqlCommand com = new SqlCommand("insert into students(SAddress,SName,SGrade) values('" + txt1 + "','" + txt2 + "','" + txt3 + "') ", con);
com.ExecuteNonQuery();
MessageBox.Show("数据库修改成功!");
con.Close();
MessageBox.Show("数据库关闭成功!");
}
}
}
SqlConnection conn = new SqlConnection(strConn);
string strCmd = "delete from tablename";
conn.Open();
SqlCommand cmd = new SqlCommand(strCmd,conn);
cmd.ExcuteNoneQuery();
conn.Close();
cmd.Dispose();
随后敲的,有些地方可能没区分大小写