我只是想知道是否可以检查 MySql
asp
表的单元格是否有值。
i'v used this to return if Database has Row/Record there
string ConnectionString = @"Server=MYSQL5011.Smarterasp.net;Database=db_9d6c52_ahmed;Uid=9d6c52_ahmed;Pwd=******;";
MySqlConnection GetConnection = new MySqlConnection(ConnectionString);
GetConnection.Open();
string VoiceorScreenSearch = "Select User_Voice ,User_Screen From User where User_Stat=@UserStat";
MySqlCommand Comand = new MySqlCommand(VoiceorScreenSearch, GetConnection);
Comand.Parameters.AddWithValue(@"UserStat", key);
MySqlDataReader ReadData = Comand.ExecuteReader();
if (ReadData.HasRows)
{
hasrowsornot = true;
}
但如果 Cell[1]
为 null
或有数据,我需要它返回!,我的单元格数据类型为 BLOB
以及这样做的技巧? ,会有帮助的 谢谢
最佳答案
你可以这样尝试:
if (!ReadData.IsDbNull(yourfield)) {
var value = ReadData.GetString(yourfield);
// some code
}
关于mysql - 检查 MySql 表中的空单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32823831/