一个很暴力很无奈的数据库随机数列生成问题
List<string> tid = new List<string>();
string sql = "select tid from dbtest;";
DBConnection db = new DBConnection();
SqlDataReader sdr = db.ExecuteReader(sql);
while(sdr.Read())
{
string id = sdr.GetValue(0).ToString();
tid.Add(id);
}
sdr.Close();
foreach (string id in tid)
{
string sql2 = "update dbtest set downloadTimes = (select cast(ceiling(rand()* 100) as int)) where tid='" + id + "';";
db.ExecuteNonQuery(sql2);
}
db.Close();
用是没什么用的..只是对于新建的门户网站空数据来说比较有用
string sql = "select tid from dbtest;";
DBConnection db = new DBConnection();
SqlDataReader sdr = db.ExecuteReader(sql);
while(sdr.Read())
{
string id = sdr.GetValue(0).ToString();
tid.Add(id);
}
sdr.Close();
foreach (string id in tid)
{
string sql2 = "update dbtest set downloadTimes = (select cast(ceiling(rand()* 100) as int)) where tid='" + id + "';";
db.ExecuteNonQuery(sql2);
}
db.Close();
用是没什么用的..只是对于新建的门户网站空数据来说比较有用