在C中,如何使用sql語句向資料庫中新增資訊

2021-03-12 01:47:48 字數 1779 閱讀 2153

1樓:拽

連線字串 = @"data source=localhost\服務bai器名du;initial catalog=資料庫名 ;integrated security=true";

sqlconnection con = new sqlconnection(連線字串);

string ss = 「sql語句

」zhi;

sql***mand *** = new sql***mand(ss, con);

con.open();

***.executenonquery();

con.close();

然後再加入sql語句「daoinsert into 表(欄位

版名,欄位名,欄位名......) values(『權相應資料』,『相應資料』.....)」就行了,記住:標點符號一定要是英文狀態下的才行

2樓:匿名使用者

連線字串copy = @"data source=localhost\伺服器名;initial catalog=資料庫名 ;integrated security=true";

sqlconnection con = new sqlconnection(連線字串);

string ss = 「sql語句」;

sql***mand *** = new sql***mand(ss, con);

con.open();

***.executenonquery();

con.close();

在c#中,如何使用sql語句向資料庫中新增資訊?

3樓:拽

連線字bai符串 = @"data source=localhost\伺服器名;initial catalog=資料庫du名 ;integrated security=true";

sqlconnection con = new sqlconnection(連線字串zhi);

string ss = 「sql語句」;

sql***mand *** = new sql***mand(ss, con);

con.open();

***.executenonquery();

con.close();

然後再加入sql語句「daoinsert into 表(欄位名,專欄位名,欄位名......) values(『相應數屬據』,『相應資料』.....)」就行了,記住:

標點符號一定要是英文狀態下的才行

visual studio用c#程式設計如何向sql表中插入textbox中輸入的資料?

4樓:志華

//資料庫連線字串

sqlconnection conn=new sqlconnection("server=.;database=db;uid=sa;pwd=123");

conn.open()

string sql="insert into tabel(***,***,***)value (***,***,' "+textbox.text+" ')";

sql***mand ***m=new sql***mand(conn,sql);

***m.executenonquery(); //執行sql語句。向資料庫中插入資料

5樓:匿名使用者

要用 c# 執行你的 insert into 語句。

6樓:匿名使用者

看一下ado.***

如何使用sql語句判斷資料庫是否已經存在

1.資料 庫if exists select 1 from master.dbo.sysdatabases where name example print database existed else print database not existed 2.表if exists select 1 ...

如何使用sql語句建立表,表中欄位有id department,其中id唯一,dpartment非空

建立表,中欄位有id department,其中id唯一,dpartment非空 create table aaaa id varchar 10 not null,department varchar 30 not null,primary key id 查詢,如何在該表中查詢部門人數大於3的部門名...

llinQ語句可以在sql資料庫中執行不

不可以!linq是微軟體.net平臺上的orm,也就是說,linq是資料向程式轉變的一箇中間層,可以將將程式的物件通過linq等orm轉變成合適的語句,儲存或修改而持久儲存在資料庫中,也可以通合適的語句,將資料庫中的記錄資料轉化為程式可用的物件,所以這個中間層被細稱為orm,實際上就是業務邏輯層的細...