如題~謝謝了~~~~
C#從SQL中把某行數(shù)據(jù)轉(zhuǎn)換成數(shù)組??????
桃花長(zhǎng)相依
2018-10-16 09:10:38
TA貢獻(xiàn)1790條經(jīng)驗(yàn) 獲得超9個(gè)贊
string sql = "select * from tablename where id = @id";
SqlConnection connection = new SqlConnection("數(shù)據(jù)庫(kù)連接字符串");
SqlDataAdapter da = new SqlDataAdapter(sql, connection);
da.SelectCommand.Parameters.AddWithValue("@id", 1);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
object[] array = ds.Tables[0].Rows[0].ItemArray;
}
舉報(bào)