更改数据库
public static string selectuser()
{
string s = "";
string sql = "select yonghuming from zhuce";
SqlConnection cn = new SqlConnection("data source=.;database=youke");
SqlDataAdapter da = new SqlDataAdapter(sql,cn);
DataSet ds = new DataSet();
da.Fill(ds);
int ret = 0;
for (int i = 0; i <= zhuceq . count() - 1; i++)
{
string s1 = ds.Tables[0].Rows[i]["yonghuming"].ToString();
if (s1.Trim() == yonghuming )
{
ret = 1;
}
}
if (ret == 1)
{
s = "用户名已经被注册";
}
else
{
zhuceq.insertone();
s = "注册成功";
}
return s;
}
在SQL数据库用这样的语句,换成ACCESS应该怎么更改呢?
{
string s = "";
string sql = "select yonghuming from zhuce";
SqlConnection cn = new SqlConnection("data source=.;database=youke");
SqlDataAdapter da = new SqlDataAdapter(sql,cn);
DataSet ds = new DataSet();
da.Fill(ds);
int ret = 0;
for (int i = 0; i <= zhuceq . count() - 1; i++)
{
string s1 = ds.Tables[0].Rows[i]["yonghuming"].ToString();
if (s1.Trim() == yonghuming )
{
ret = 1;
}
}
if (ret == 1)
{
s = "用户名已经被注册";
}
else
{
zhuceq.insertone();
s = "注册成功";
}
return s;
}