[問題] SqlDataAdapter to DataTable 問題
================我的連接sql code============
string sql_string = "select Post_Day, 價格 From test_db.dbo.BarCharData";
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=RX-0\SQLEXPRESS;Initial
Catalog=test_db;Integrated Security=True";
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql_string, con);
DataTable dt = new DataTable();
sda.Fill(dt);
========================================
為什麼是寫成sda.Fill(dt)呢
之前不都是
class myClass
{
public string test(string myWord)
{
return myWord+"^^";
}
}
a = myClass.test("安安")
就我的想像 dt裡面應該是空的 等sda.Fill之後才會填滿他
但這樣不是應該是寫成dt.Fill(sda)嗎
我查過官網了 但還是覺得這邊怪怪的 是只有這邊比較特別嗎
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 106.1.129.194
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1458220663.A.B57.html
→
03/17 22:40, , 1F
03/17 22:40, 1F
→
03/17 23:04, , 2F
03/17 23:04, 2F
→
03/17 23:18, , 3F
03/17 23:18, 3F
→
03/18 09:31, , 4F
03/18 09:31, 4F
→
03/18 09:31, , 5F
03/18 09:31, 5F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):