C連線資料庫,那個能提供個類,能增刪改查的初學者

2021-03-04 08:53:54 字數 2867 閱讀 7823

1樓:匿名使用者

我用的開發工具是visual studio 以sql server為例:

首先得在專案裡面匯入命名空間:

sql server 匯入:using system.data.sqlclient

然後就可以用連線資料庫的五大物件:

sqlconnection(連線物件),sql***mand(命令物件),sqldatareader(資料閱讀器),sqldataadapter(資料介面卡),dataset(記憶體集)

2樓:匿名使用者

sqlconnection此類連線資料庫,sql***mand、sqldataadapter、sqldatareader是運算元據的,自己先去學些ado.***的基礎吧

3樓:

sql***mand,sqldatareader,sqldataadapter

求c#winform 資料庫類(連線和增刪改查)和在視窗中的呼叫**

4樓:匿名使用者

新增引用

using system.data;

using system.data.sqlclient;

定義資料庫

5樓:

c# 中分為三層,在資料訪問層中寫增刪查改的**和專門連線資料庫的乙個類寫connection;在視窗中呼叫的**一般寫在表示層。

6樓:蒲仕龍

喔,這個沒有什麼的哈,就是乙個連線到資料庫,然後就是sql語句了哈

我們需要做乙個資料庫系統。用c#做介面,然後實現增刪改查的功能。請問該怎麼連線到資料庫。

7樓:yl陳

using system.data.sqlclient;

string str = "data source=. //伺服器名 ;initial catalog=newsfbmod;uid=sa//使用者

名;pwd=652180//密碼";//連線資料庫

sqlconnection ** = new sqlconnection(str);

**.open();//開啟資料庫

cd.connection = **;

cd.***mandtext = "select * from 型別列表";//查詢

sqldatareader cmd = cd.executereader();//讀取

sql***mand cmd = new sql***mand("update 使用者列表 set 賬號= '" + textbox1.text + "',密碼='" + textbox2.text + "',性別='" + textbox3.

text + "',使用者型別='" + ***bobox1.text + "' where 使用者名稱='" + listbox1.text + "'", con);

cmd.executenonquery(); //修改

sql***mand cmd = new sql***mand("delete from 使用者列表 where 使用者名稱='" + listbox1.text + "'", con);

cmd.executenonquery(); //刪除

string str3 = "insert into 使用者列表(賬號,密碼,使用者名稱,性別,使用者型別) values('" + textbox1.text + "','" + textbox2.text + "','" + textbox4.

text + "','" + textbox3 . text + "','"+***bobox1 .text +"')";

sql***mand cmd = new sql***mand(str3, con); //增加

8樓:匿名使用者

最簡單的方法是使用struts或jsf等mvc的框架,本身就是乙個實現。如果自己實現,比較複雜的就是要自己寫乙個總控制器,接受所有使用者的請求,進行分發給其他servlet或直接進行頁面跳轉。不建議自己實現,建議使用乙個mvc框架

9樓:匿名使用者

如果你是windows身份驗證:string connectionstring ="server=.;database=你的資料庫名字;integrated security=sspi";

如果是sql server 身份驗證:string connectionstring ="server=.;database=你的資料庫名字;userid=sa;password=sa「

這裡的userid和password是你自己在選擇資料庫是設定的

10樓:匿名使用者

sqlconnection mysql = new sqlconnection("server=127.0.0.

1;database=xieyudong;uid=sa;pwd=123456");

sqldataadapter mytable = new sqldataadapter("select * from a", mysql);

mysql.open();

string sqlstr = "delete from a where id='" + gridview1.datakeys[e.rowindex].

value.tostring() + "'";

sql***mand sql*** = new sql***mand(sqlstr, mysql);

sql***.executenonquery();

mysql.close();

bind();

11樓:匿名使用者

上網搜乙個sqlhelper非常簡單就連上了。。。

c連線資料庫的步驟是什麼,C 中連線資料庫的程式碼是什麼 寫在什麼地方的

c 連線資料庫有以下幾個步驟 1 使用配置的資料庫連線串,建立資料庫連線 connection 物件 2 構建操作的sql語句 3 定義command物件 4 開啟資料連線 5 執行命令 舉乙個例子,刪除操作 public class studentservice stuid 定義command物件...

java連線資料庫為什麼要實體類

實體類具有封裝的屬性,正好對應資料庫中表的字段,這樣很方便,易於維護 不明白你的意思,java連線資料庫最簡單的通過jdbc來連線,這與實體類沒有任何關係啊!不知道你想表達什麼意思?java 與資料庫對應的實體類 字段為什麼用integer而不用int 返回資料庫字段值是null的話,int型別會報...

C怎樣不用sql,而又可以連線資料庫檔案

vs裡面有自帶的小型資料庫 你點建立資料庫裡面倒數第二個 不行.必須使用 mssql的資料庫引擎載入 資料檔案.vs裡面自帶有sqlserver,所以你只需新增乙個資料庫連線就行了 c 怎麼實現直接連線資料庫的檔案,而不用想sql server資料庫還要附加?vs中新建空 在 路徑那點右鍵,新建項。...