我想從MySQL數據庫中獲取數據列說,我有多行數據的特定列,我需要包括每一行取回後的昏迷。每次獲取後取回Mysma數據與昏迷C#Mysql
這是給數據前,當我試圖
添加代碼Response.Write(name.Split(','));
System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]System.String[]
我的DB
Phone_Number School_id
1 SC1
2 SC1
3 SC1
4 SC1
期望輸出
1,2,3,4
後
電流輸出增加昏迷3210
我取查詢
string constr = ConfigurationManager.ConnectionStrings["Logging"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(constr))
{
using (MySqlCommand MySqlCommand = new MySqlCommand("SELECT Phone_Number FROM Login where SchoolId='" + SessionManager.SchoolId + "'", con))
{
MySqlCommand.CommandType = CommandType.Text;
con.Open();
MySqlDataReader MySqlDataReader = MySqlCommand.ExecuteReader();
while (MySqlDataReader.Read())
{
string name = MySqlDataReader["FatherFullName"].ToString();
Response.Write(name.Split(','));
}
con.Close();
}
}
謝謝完全一樣,我期待現在我有一個更多的問題,我認爲你可以整理出來的問題是說,如果有一個空白或空ENTRE返回',,,,,,,'這樣的 – Shaik
@Shaik你可以用['string.IsNullOrEmpty'](https://msdn.microsoft.com/en-us/library/system)檢查你的字符串。string.isnullorempty.aspx)然後。更新我的答案,看看。 –
對不起,如果我想避免一些文本,如默認情況下保存在數據庫像'XXXXXXXXXXXXX'那麼我應該怎麼做,如果(!string.IsNullOrEmpty(名稱)&&!字符串。) – Shaik