我需要在数据库中检查当前值是否存在。但我不知道如何在我的值public Text CreateUsername中使用数据。
[SerializeField]
private Text CreateUsername;
创建用户查询
public void CreateUser(string username, int status)
{
using (IDbConnection dbConnection = new SqliteConnection(Connection))
{
dbConnection.Open();
using (IDbCommand dbCmd = dbConnection.CreateCommand())
{
string insertuser = String.Format("insert into user_data (UserData_name, UserData_status) values (\"{0}\",\"{1}\")", username, status);
dbCmd.CommandText = insertuser;
dbCmd.ExecuteScalar();
dbConnection.Close();
}
}
}
插入用户查询...在此过程中,我不知道在字符串checkusername中的什么条件下使用什么正确的查询。
public void insertCreateUser()
{
using (IDbConnection dbConnection = new SqliteConnection(Connection))
{
dbConnection.Open();
using (IDbCommand dbCmd = dbConnection.CreateCommand())
{
string checkusername = "select count(UserData_name) from user_data where UserData_name ";
dbCmd.CommandText = updatestatus;
dbCmd.ExecuteScalar();
dbConnection.Close();
}
}
ChangeStatus();
int stat = 1;
CreateUser(CreateUsername.text, stat);
}