c窗體中如何將資料庫中的值給label控制元件的文字資訊

2021-05-17 17:49:37 字數 4933 閱讀 4054

1樓:唐城冬

你要把結果先給datatable變數,再從這個變數賦值給控制元件,

label1.text=dt.rows[1]["欄位名"].tostring();

windows程式中怎樣將資料庫中的資料顯示在label控制元件上(c#)

c#如何用lable控制元件,將資料庫中查詢到的值顯示出來?求完整的**

2樓:匿名使用者

放在已個按鈕事件下面,先說,如果有錯,你要除錯哈,要引用命名控制元件才可以哦

string connectionstring=「integrated security=sspi;persist security info=false;initial catalog=myproject;data source=.」

string sql="select * from 你的表名";

using (sqlconnection connection = new sqlconnection(connectionstring))

sdr.close();

sdr.dispose();

connection.close();

connection.dispose();

}catch (exception ex)}搞定

c#如何將資料庫的值傳遞在窗體的文字框中?

3樓:雲之凡

最基本的ado.***要連線資料庫

大致**:button 事件()

dr.close();

conn.close()}

4樓:匿名使用者

首先要看你用的是什麼控制元件,在其上面判斷你選中的那一列 根據其下標來顯示資訊例如你學號就是0,姓名就是1

5樓:匿名使用者

通過學號查詢啊,然後將查詢的資料填充到相應的控制元件上去。

6樓:匿名使用者

你可以按鈕處理函式裡面。進行資料庫的查詢操作啊。。

然後將查到的資料儲存到textbox裡面就可以了啊

c#中如何讓label顯示資料庫裡的內容呢?

7樓:學好知識

1,首先你得把資料從資料庫中讀到程式中。

2,然後把讀出來的值賦給lable的text屬性就可以了。

8樓:胤晟颸綦恪

為什麼用label呢 直接資料繫結就好了

c#怎樣把資料庫的資訊顯示到lable上

9樓:匿名使用者

在頁面上加一個label

id為lblname

lblname.text="姓名"

這樣不行嗎?

10樓:匿名使用者

datatable dt = new datatable();

dt.columns.add("rname", typeof(string));

datarow dr = dt.newrow();

string strsql = "select 真實姓名 from 表名 where 姓名='輸入的專姓屬名'";

dr["rname"] = strsql;

dt.rows.add(dr);

label.text = dt.rows[0]["rname"].tostring();

11樓:匿名使用者

後臺: select 使用者真版實姓權名 from 表

aspx: 真實

姓名') &> />

12樓:匿名使用者

label1.text="";

13樓:

以前我用過gridview控制元件,你可以試試,應該能繫結所有你要的資料

c# winform 如何把資料庫裡面的內容賦值給textbox

14樓:匿名使用者

//sql語句string sql = string.format("select text from test where id = )", 1);

//資料庫名

為temp.mdb,表為test,包含2個欄位:id 和 text

string dbconnectionstring = "data source=***puter-pc;user id=sa;password=123456;initial catalog=temp;pooling=true";

sqlconnection con = new sqlconnection(dbconnectionstring);

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

cmd.***mandtype = ***mandtype.text;

sqldatareader myreader;

con.open();

myreader = cmd.executereader();

textbox1.text = myreader["text"].tostring();

messagebox.show("完成!", "系統提示", messageboxbuttons.ok, messageboxicon.information);

cmd.cancel();

myreader.close();

15樓:

解決幾步就行了,首先連線資料庫,讀取資料 繫結控制元件 textbox.text=資料庫取出值

sqldatareader

16樓:雷鋒雷鋒

第一步 查詢資料庫

第二布 賦值

c#怎樣把資料庫查詢到的資訊顯示到lable上+c#怎樣把資料庫查詢到的信

17樓:靈兒

直接往label的text屬性,加資訊不就好了? 根據你登入的使用者名稱做條件查詢,得出的資料集逐步加到label裡。 this.

label.text+= ds.tables[0].

columns["真實姓名"].tostring();

18樓:第470位訪客

根據你登入進去的使用者名稱獲取到該使用者所有的詳細資訊。然後將使用者的資訊一一加入到label.text中 有一個user物件,有name,password,***pname,validatetime,phone,fzname,現在你要將得到的資訊一一賦給每個label,則為:

user user = new user(); lblname.text=user.name; lbl***pname.

text=user.***pname; lblvalidatetime.text=user.

validatetime.tostring(); lblphone.text=user.

phone.tostring(); lblfzname.text=user.

fzname; 這樣就把你取得的每個值分別賦給label了。

如何將資料庫資訊顯示到c#textbox控制元件裡

19樓:匿名使用者

是不是可以bai這樣理解 - 把登陸

du窗體zhi中textbox和***bobox中的值傳到窗體2,然後在窗體2用textbox顯示dao

出來?如果是這樣內的話--首先在窗體2中定義2個變容量用來接收從登陸窗體傳過來的值

窗體2定義的變數用public修飾

public string name = "";

public string type = "";

form2窗體的load方法

textbox1.text = name + type;

在登陸窗體的button按鈕裡面寫

from2 f2 = new form2();

f2.name = this.textbox1.text;

f2.type = this.***bobox1.selecteditem.tostring();

f2.show();

另外,團idc網上有許多產品**,便宜有口碑

20樓:

private void databind()

在窗體載入時呼叫這個方法。

21樓:匿名使用者

先把值從資料庫抄取出襲來 然後賦值給已經定義好的控制元件就可以了!程式載入的時候執行

txtname.text=dt.rows[0]["name"].tostring();

txt***.text=dt.rows[0]["***"].tostring();

22樓:匿名使用者

protected void page_load(object sender, eventargs e)

private static sqlconnection connection;

public static sqlconnection connection

else if (connection.state == system.data.connectionstate.closed)

else if (connection.state == system.data.connectionstate.broken)

return connection;

}private void getstudent()

我是從「上海全鼎軟體學院」畢業的——62616964757a686964616fe4b893e5b19e31333264643236——————

23樓:匿名使用者

把資料從資料庫表中取出來,直接用控制元件接就可以了

如何將mysql資料庫中的表匯入到另mysql資料庫中

db1為原資料庫,db2為要匯出到的資料庫,fromtable 是要匯出的表名 1.方法一 登入匯出到的資料庫,執行 create table fromtable select from db1.fromtable 2.方法二 在cmd下執行,mysqldump u root p db1 fromt...

C中如何用textbox查詢sql資料庫裡的資料並顯示在d

其實很簡單。我們只需要在窗體上拖放一個datagridview然後雙擊窗體空白處,在 檔案的form1 load事件中新增括號裡的 private void form1 load object sender,eventargs e 即可,sqlconnection conn new sqlconne...

Oracle如何在將資料庫中的所有表都加上某些欄位

declare vstr sql varchar2 2000 cursor c1 is select distinct a.table name table name from user tab columns a where a.table name not in select b.table n...