日期:2014-05-17 浏览次数:20944 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
namespace WinFrom数据操作
{
public partial class frmManager : Form
{
public frmManager()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) //查看,感觉好像没什么实际作用..
{
string sql = "select * from DB1";
SqlConnection conn = new SqlConnection(@"server=.;uid=user1;pwd=111;database=use");
SqlCommand cmd = new SqlCommand(sql, conn);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
private void button2_Click(object sender, EventArgs e) //插入,关于年龄的判断语句加在这里比较好吗?
{
int n = 0;
string sql = "insert into DB1(编号,姓名,年龄,婚否,入职时间,工资,好友,利率,职位,备注) values (@编号,@姓名,@年龄,@婚否,@入职时间,@工资,@好友,@利率,@职位,@备注)";
if (textBox2.Text.Trim() ==&nbs