hi to all,
private double function()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["stockforecasting"].ConnectionString);
con.Open();
double d1 = 0, sum = 0;
SqlDataAdapter adp = new SqlDataAdapter("select eps,pbya,normalisation from stock where pricedate between '" + txtstartdate.Text + "' AND '" + txtenddate.Text + "'", con);
DataSet ds = new DataSet();
adp.Fill(ds, "stock");
if (ds.Tables["stock"].Rows.Count - 1 > 0)
{
for (int i = 0; i < ds.Tables["stock"].Rows.Count; i++)
{
double eps = 0, pbya = 0, normalise = 0,a1=0;
for (int j = 0; j < 3; j++)
{
double d3 = 0;
string str = ds.Tables["stock"].Rows[i][j].ToString();
d1 = Convert.ToDouble(str);
if (j == 0)
{
Random rnd = new Random();
double value = rnd.NextDouble();
a1 = value;
d3 = d1 * value;
eps = d1;
SqlCommand cnd = new SqlCommand("insert into stock3(startdate,enddate,eps,weight) values('" + txtstartdate.Text + "','" + txtenddate.Text + "','" + d1 + "','" + value + "')", con);
cnd.ExecuteNonQuery();
}
else if (j == 1)
{
Random rnd = new Random();
double value1 = rnd.NextDouble();
d3 = d1 * value1;
pbya = d1;
SqlCommand cnd = new SqlCommand("update stock3 set pbya='" + d1 + "',weight1='" + value1 + "' where weight='" + a1 + "' ", con);
cnd.ExecuteNonQuery();
}
else if (j == 2)
{
Random rnd = new Random();
double value2 = rnd.NextDouble();
d3 = d1 * value2;
normalise = d1;
SqlCommand cnd = new SqlCommand("update stock3 set normalise='" + d1 + "',weight2='" + value2 + "' where weight='" + a1 + "' ", con);
cnd.ExecuteNonQuery();
}
sum = sum + d3;
}
}
}
con.Close();
return sum;
}
here is my code. i called this function 3 times. its working. but if i put the breakpoint , the regular loop works. if i remove the breakpoints,it generates same random values. i dont know wat to do