c#随机数Random怎么每次都是一样的呀。
privatevoidbutton1_Click(objectsender,EventArgse){Randomrd=newRandom();stringstr="ser...
private void button1_Click(object sender, EventArgs e)
{
Random rd = new Random();
string str="server=(local);database=ConsultationDB;uid=sa;pwd=111";
string sqlselect = "select * from client_ProductInfo where CompanyID=" + textBox1.Text;
SqlConnection conn=new SqlConnection(str);
SqlCommand comm = new SqlCommand(sqlselect,conn);
SqlDataAdapter sda = new SqlDataAdapter(comm);
//sda.SelectCommand.CommandText = sqlselect;
DataSet ds = new DataSet();
conn.Open();
comm.ExecuteNonQuery();
sda.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
String sqlinsert = "update client_ProductInfo set Hits=" + rd.Next(1000,5000) + " where CompanyID=" + textBox1.Text;
comm.CommandText = sqlinsert;
comm.ExecuteNonQuery();
}
MessageBox.Show("ok");
}
哪里错了呢 展开
{
Random rd = new Random();
string str="server=(local);database=ConsultationDB;uid=sa;pwd=111";
string sqlselect = "select * from client_ProductInfo where CompanyID=" + textBox1.Text;
SqlConnection conn=new SqlConnection(str);
SqlCommand comm = new SqlCommand(sqlselect,conn);
SqlDataAdapter sda = new SqlDataAdapter(comm);
//sda.SelectCommand.CommandText = sqlselect;
DataSet ds = new DataSet();
conn.Open();
comm.ExecuteNonQuery();
sda.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
String sqlinsert = "update client_ProductInfo set Hits=" + rd.Next(1000,5000) + " where CompanyID=" + textBox1.Text;
comm.CommandText = sqlinsert;
comm.ExecuteNonQuery();
}
MessageBox.Show("ok");
}
哪里错了呢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询