>>> test_df03.select('label').distinct().orderBy('label').show()
+-----+
|label|
+-----+
| 1|
| 2|
| 3|
+-----+
我如何检查Database.Insert方法是否返回null
答案 0 :(得分:2)
不是最好的,但下面的代码将帮助您检查空值
bool found;
using (SqlCommand cmd = new SqlCommand("SELECT * FROM userdata WHERE name = @name", connection))
{
connection.Open();
cmd.Parameters.AddWithValue("@name", name);
SqlDataReader reader = cmd.ExecuteReader();
if(reader.read())
found = true
else
found = false;
connection.Close();
}