插入 刪除和更新資料

2022-07-15 08:36:09 字數 554 閱讀 9101

//

定義乙個需要訪問的資料庫的資訊

string strcon = "

server=pc-20161029wdcv\\sql2014;database=studentdb;trusted_connection=true";

sqlconnection con = new

sqlconnection(strcon);

con.open();

//把sql語句換成刪除和更新,即可實現刪除和更新操作

string sql=「insert into student (學號,姓名,性別,出生時間,專業)values('

001','

張三','

女',『1989-11-21』,'

計算機'

)」;sqlcommand cmd=new

sqlcommand(sql,con);

cmd.executenonquery();

con.close();

messagebox.show(

"新增成功!

");

資料插入更新刪除

insert into 表名 values 值1,值2 insert into student id,name,age,email value 1 張三 18 男 zhangsan 163.com insert into 表名 欄位名1 欄位名2 value 值1,值2 insert into 表名...

資料 更新 插入 刪除

1.update實現對資料的更新操作,語法如下 更新單行資料 update dbtab set f1 g1 fn gn where f表組建欄位名,g為新設定的值,where為確保只更新單行。注 除f g外還可 f f g f f g 通過工作區更改單行資料 update dbtab from wa...

插入更新刪除資料

插入資料 insert into mytable id,name,age values 1,xxiang,23 從別的表中資料插入到mytable中 insert into my id,name,age select id,name,age from othertable 從別的表中資料插入到新的表...