剛開始學習資料庫,然后想通過C#讀取access資料庫中滿足條件的一條資料顯示在label控制元件中,代碼如下
connection1.Open();
string xuehao = "123456";
string sql3 = "select name from studentInfo where [studentnumber]=" + xuehao;
OleDbDataAdapter da = new OleDbDataAdapter(sql3, connection1);
DataTable dt = new DataTable(); //新建表物件
da.Fill(dt,"student"); //用適配物件填充表物件
label1.Text = ds.Tables["student"].Rows[0].ToString().Trim();
一直在報錯

這個是什么原因呢,求大咖指點一下,謝謝!!
xuehao對應的文本型別在資料庫中是短文本型別。
uj5u.com熱心網友回復:
不知道先檢查以下有沒有回傳結果
第二 獲取第一行第一列運算式
ds.Tables["student"].Rows[0]["name"].ToString()
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/79537.html
標籤:Access
上一篇:MySQL-5.7版本真的可以做到不丟資料的故障切換嗎?
下一篇:Dlookup困惑,求幫忙
