代码
private void button1_Click(object sender, EventArgs e)
{
string strconn = "Data Source=localhost;Initial Catalog=Large;Persist Security Info=True;User ID=sb;Password=juanjuan";
string queryString = "SELECT * FROM news WHERE name = @uname";
SqlDataAdapter adapter
= new SqlDataAdapter(queryString, strconn);
adapter.SelectCommand.Parameters.Add(
"@uname", SqlDbType.NVarChar, 50, "name").Value = textBox1.Text; //搜索 用where

new SqlCommandBuilder(adapter);
DataSet ds
= new DataSet();
adapter.Fill(ds,
"yyqtab");
DataTable dtable
= ds.Tables["yyqtab"];
/*textBox2.Text = (string)ds.Tables["yyqtab"].Rows[0][1]; //提取
textBox2.Text = (string)ds.Tables["yyqtab"].Rows[0][1];//
*/
ds.Tables[
"yyqtab"].Rows[0].Delete(); // 搜索数据库里的数据并删除所搜到的东西

/*DataRow workRow = dtable.NewRows(); //插入
workRow[0] = textBox1.Text ;
workRow[1] = textBox2.Text;
dtable.Rows.Add(workRow);//
*/
/*ds.Tables["yyqtab"].Rows[0][0] = textBox1.Text; //更新
ds.Tables["yyqtab"].Rows[0][1] = textBox2.Text;
*/
//ds.Tables["yyqtab"].Rows[0].Delete(); // 删除


adapter.Update(ds,
"yyqtab");


/*textBox1.Clear();
textBox2.Clear();
*/
//this.Close();

//string a = @"F:\g.txt";
//string s = textBox1.Text;
//File.WriteAllText(queryString, s);

}

设计视图

SQL几种简单的语法

数据库为Large

SQL几种简单的语法

 

相关文章:

  • 2021-07-03
  • 2021-08-01
  • 2021-12-16
  • 2021-09-11
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2021-10-05
  • 2021-11-05
  • 2022-12-23
  • 2021-05-31
  • 2021-07-12
相关资源
相似解决方案