求助,c怎麼讀取SQL資料然後顯示出來

2021-03-04 08:53:54 字數 1574 閱讀 5275

1樓:匿名使用者

string sql=「"//資料庫查詢語句connection con=new connection(connstring);

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

con.open();

sqldatareader dr=cmd.excutereader;

if(dr.read())

dr.close();

con.close();

c#中怎麼讀取sql資料庫表中的資料後顯示在乙個textbox中

2樓:匿名使用者

private void getdatabyparmsql***mand()

catch (exception ee)

finally}

3樓:乖乖

string connstring=//連線字串string sql=「"//資料庫查詢語句connection con=new connection(connstring);

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

con.open();

sqldatareader dr=cmd.excutereader;

if(dr.read())

dr.close();

con.close();

4樓:匿名使用者

樓上所說可以··

但是如果確定是身份證的話···

那就是唯一的···

唯一的用model 物件返回單一的足以···不需要用到dataset

不知道你的專案中寫了實體類沒有!

返回乙個實體類就足以

5樓:匿名使用者

先定義乙個textbox空間 名為tb1

點選按鈕執行

select * from man where 身份證號=『「+tb1.text+」』

返回datatable資料 將dt中的資料dt.row[*][「姓名」]dt.row[*][「年齡」]賦值給tb1

例如tb1.text=「姓名:」+dt.row[*][「姓名」].tostring()+"年齡:"+dt.row[*][「年齡」].tostring()

不知道這樣能不能實現你的功能

6樓:天地梁心

把資料讀到之後存在乙個變數裡面,然後把變數顯示在textbox就行了啊

7樓:百度使用者

把sql語句查出的資料放進一張表裡,在逐個顯示就行了,判斷查出的表的行數是否為0,如果為0則用messagebox顯示「所查資料不存在」

c#如何從sql資料庫中取資料,然後顯示到label中

8樓:匿名使用者

if (datareader.read()) }

在這裡下斷點,看看這裡得到的sign是不是你要的資料。

9樓:匿名使用者

設斷點除錯過沒? 你確定獲取到了資料庫中的資料?

C中怎麼讀取SQL資料庫表中的資料後顯示在TEXTBO

private void getdatabyparmsql mand catch exception ee finally string connstring 連線字串string sql 資料庫查詢語句connection con new connection connstring mand cm...

c連線SQL資料庫的問題,c 連線SQL資料庫的問題

用程式連線需要開啟遠端連線 1在 sql server management studio 的物件資源管理器中,右鍵單擊伺服器,再單擊 屬性 2.在 安全性 頁上的 伺服器身份驗證 下,選擇混合驗證模式,密碼,再單擊 確定 3.在 sql server management studio 對話方塊中...

C怎麼迴圈讀取ini檔案裡的資料資料在域下

class inireadwrite 下面完成和上面迴圈一樣的內容 string temp system.text.encoding.default.getstring buffer temp temp.replace 0 temp temp.trimend string arrstring tem...