C#小白,关于for循环的一个问题。
这段for循环,如果执行到 MessageBox.Show("1同一整点,公共信息表中存在相同站点"); 这一句,就.一.直.跳.弹.出.窗.口,我想.在.这.后.面.个continue,但.是.也.没.用,一.直.重.复.执.行i=0,是哪.里.有问.题呢?
for (int i = 0; i < ds.Tables["info"].Rows.Count;i++ )//
{
exist ex = new exist();
if (ex.isexit(ds.Tables[0].Rows[i][0].ToString(), strdt))
{
DataCon dc = new DataCon();
SqlConnection sqlcon1 = dc.SqlgetCon();
sqlcon1.Open();
string strcom1 = "select top 1 Eg,UVA from hour_solar_data where Station_ID='" + ds.Tables[0].Rows[i][0].ToString() + "' and Date_Time='" + strdt + "'";
SqlDataAdapter sqldataadapter = new SqlDataAdapter(strcom1, sqlcon1);
DataSet mydataset = new DataSet();
sqldataadapter.Fill(mydataset, "data");//
sqlcon1.Close();
bool UVA = checkUlRadiation(int.Parse(mydataset.Tables["data"].Rows[0][1].ToString()));
bool Eg = checkToRadiation(int.Parse(mydataset.Tables["data"].Rows[0][1].ToString()));
if (UVA && Eg)
{
//
if (ex.PubInfo(ds.Tables[0].Rows[i][0].ToString(), strdt))
{
MessageBox.Show("1同一整点,");
}
else
{
string strcom2 = @"INSERT INTO PubInfo(Programnum,Programname,ObserTime,UpdateTime,Status)
VALUES('" + ds.Tables["info"].Rows[i][0] + "','" + ds.Tables["info"].Rows[i][1] + "','" + strdt + "','" + DateTime.Now + "','0')";
DataOperate dataoper = new DataOperate();
OleDbCommand oledbcom = dataoper.AccDataComm(strcom2);
oledbcom.ExecuteNonQuery();
}
}
for (int i = 0; i < ds.Tables["info"].Rows.Count;i++ )//
{
exist ex = new exist();
if (ex.isexit(ds.Tables[0].Rows[i][0].ToString(), strdt))
{
DataCon dc = new DataCon();
SqlConnection sqlcon1 = dc.SqlgetCon();
sqlcon1.Open();
string strcom1 = "select top 1 Eg,UVA from hour_solar_data where Station_ID='" + ds.Tables[0].Rows[i][0].ToString() + "' and Date_Time='" + strdt + "'";
SqlDataAdapter sqldataadapter = new SqlDataAdapter(strcom1, sqlcon1);
DataSet mydataset = new DataSet();
sqldataadapter.Fill(mydataset, "data");//
sqlcon1.Close();
bool UVA = checkUlRadiation(int.Parse(mydataset.Tables["data"].Rows[0][1].ToString()));
bool Eg = checkToRadiation(int.Parse(mydataset.Tables["data"].Rows[0][1].ToString()));
if (UVA && Eg)
{
//
if (ex.PubInfo(ds.Tables[0].Rows[i][0].ToString(), strdt))
{
MessageBox.Show("1同一整点,");
}
else
{
string strcom2 = @"INSERT INTO PubInfo(Programnum,Programname,ObserTime,UpdateTime,Status)
VALUES('" + ds.Tables["info"].Rows[i][0] + "','" + ds.Tables["info"].Rows[i][1] + "','" + strdt + "','" + DateTime.Now + "','0')";
DataOperate dataoper = new DataOperate();
OleDbCommand oledbcom = dataoper.AccDataComm(strcom2);
oledbcom.ExecuteNonQuery();
}
}
...全文
相关推荐
c#用for语句输出一个三角形的方法
在C#编程中,遇到一个独特的面试挑战:仅使用一个for循环输出一个三角形。通常情况下,如果允许使用嵌套循环,这个任务会相对简单,但题目限制只能使用一个for循环,这就增加了问题的复杂性。解决这个问题的
C#中foreach循环对比for循环的优势和劣势
例如,遍历一个数组,使用foreach只需要一行代码,而for循环通常需要多行来初始化、判断和递增索引。
C#循环案例
掌握for循环的使用,可以帮助我们更好地解决问题,提高编程效率。
c#九九乘法表for嵌套
在C#中实现这个功能,主要涉及到循环结构(for循环)和控制台输出。下面我们将详细介绍这个过程。1. **基础语法** 在C#中,我们首先需要创建一个控制台应用程序项目。
for循环打出图形的代码
无论是C#还是Java,理解并熟练运用for循环都是编程基础的重要组成部分,它将帮助你解决许多实际问题,包括数据处理、算法实现以及游戏开发等。


