private void button2_Click(object sender, EventArgs e)
{
SqlConnection myconnection = new SqlConnection();
myconnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename='D:\\数据库\\qq DATA.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = myconnection;
sqlcommand.CommandType = CommandType.Text;
sqlcommand.CommandText = "SELECT * FROM 用户信息";
Sql_Data_Adapter = new SqlDataAdapter();
ds=new DataSet();
Sql_Data_Adapter.SelectCommand = sqlcommand;
Sql_Data_Adapter.Fill(ds, "用户信息");
try//////这里直接跳过了,不知道有什么问题
{
DataRow dr = ds.Tables["用户信息"].NewRow();
dr["用户名"] = textBox1.Text;
dr["密码"] = Int32.Parse(textBox2.Text);
//怎样添加 编号
ds.Tables["用户信息"].Rows.Add(dr);
Sql_Data_Adapter.Update(ds, "用户信息");
}
catch (Exception ee)
{
MessageBox.Show("创建失败");
}
}
{
SqlConnection myconnection = new SqlConnection();
myconnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename='D:\\数据库\\qq DATA.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = myconnection;
sqlcommand.CommandType = CommandType.Text;
sqlcommand.CommandText = "SELECT * FROM 用户信息";
Sql_Data_Adapter = new SqlDataAdapter();
ds=new DataSet();
Sql_Data_Adapter.SelectCommand = sqlcommand;
Sql_Data_Adapter.Fill(ds, "用户信息");
try//////这里直接跳过了,不知道有什么问题
{
DataRow dr = ds.Tables["用户信息"].NewRow();
dr["用户名"] = textBox1.Text;
dr["密码"] = Int32.Parse(textBox2.Text);
//怎样添加 编号
ds.Tables["用户信息"].Rows.Add(dr);
Sql_Data_Adapter.Update(ds, "用户信息");
}
catch (Exception ee)
{
MessageBox.Show("创建失败");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货