带循环和一定时间间隔的多个SQL查询 [英] multiple sql query with loop and some time interval

查看:94
本文介绍了带循环和一定时间间隔的多个SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想使用循环执行多个sql查询,并且我希望这些查询以一定的时间间隔执行.

Hi,

I want to perform multiple sql query with loop and i want these queries perform with some time interval.

SqlConnection sqlconn = new SqlConnection(str);
            sqlconn.Open();
            string strquery;
            strquery = "SELECT Indices_id, IndicesName, LastPrice, ChangePrice * .63 AS 'change of price', Percentage FROM Table1";
            strquery2 = "SELECT Indices_id, IndicesName, LastPrice, ChangePrice * .60 AS 'change of price', Percentage FROM Table1";
            strquery3 = "SELECT Indices_id, IndicesName, LastPrice, ChangePrice * -.60 AS 'change of price', Percentage FROM Table1";
            SqlCommand sqlcmd = new SqlCommand(strquery, sqlconn);
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter();
            sda.SelectCommand = sqlcmd;
            sda.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();

推荐答案

为此尝试使用并行for循环.

这是一个例子.这个的.您将对每个这些SQL查询都拥有很多控制权.

http://msdn.microsoft.com/en-us/library/dd460713.aspx [ ^ ]
try using parallel for loop for this.

here is an eg. of this. you will have much control on each of these SQL queries.

http://msdn.microsoft.com/en-us/library/dd460713.aspx[^]


这篇关于带循环和一定时间间隔的多个SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆