iT邦幫忙

0

C# SELECT 後的data 如何取得 剩個table的值呢?

這是我看做的好 select sql 後 將 取得的資料 丟到 GridView 裡

但我現在想要將 select 的值 另外在 取得 某個table 的值 秀在 Label 或是 textbox 裡

不知該怎麼寫 謝謝~!

        protected void Button1_Click(object sender, EventArgs e)
        {
            string aaa = TextBox1.Text;

            if(aaa!=""){
            SqlConnection conn = new SqlConnection("Data Source=IP;Initial Catalog= name ;Persist Security Info=True;User ID=aaa;Password=bbbb");
            conn.Open();
            string selectCmd = "SELECT * " +
                               "FROM uBIQ_QA002 "+
                               "where processSerialNumber='" + aaa + "' ";
            SqlDataAdapter da = new SqlDataAdapter(selectCmd, conn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            this.GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
            da.Dispose();
            conn.Close();
            }
        }
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
player
iT邦大師 1 級 ‧ 2014-05-27 19:55:43
最佳解答

再跑這行前
this.GridView1.DataSource = ds.Tables[0];

先抓出你的資料啊, 例如
//總資料筆數
int TotalCount = ds.Tables[0].Rows.Count;

//第0列, 欄位名為x的資料
string x = ds.Tables[0].Rows[0]["x"].ToString();

依此類推

我要發表回答

立即登入回答