以K字开头的字段插入随机数据?
不理解..
随机数的话是Random

解决方案 »

  1.   

    在DataTable里面处理;你要找到你要的列然后添加随机数就行了
    rand().Next();
      

  2.   

    Random r = new Random();
            int x = r.Next(100, 200);
            string cc = "K"+Convert.ToString(x);
          
            StringBuilder str = new StringBuilder();
            str.Append("insert into 表("+cc+")");
            str.Append(" values(@kk)");
      

  3.   

    private float GetRandomint(int min,int max)
        {
            Random random = new Random();
            return (random.Next(min, max));
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            float x = -1;
            string str1 = "";
            Myclass class1 = new Myclass();
            DataSet ds2 = class1.GetAllFieldsDaitanMingxiBennian();
                
                for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                {
                    str1 = ds2.Tables[0].Rows[j][0].ToString();
                    if (str1.Substring(0, 1) == "K")
                    {
                        x = GetRandomint(0, 9999);
                        class1.ExecuteSql("update DaitanMingxiBennian set " + str1 + "=" + x.ToString() + " where ID < 100");
                    }
                }
        }
    看看哪里不对呀