标题:【求助】dataAdapt填充指令执行时自动退出,无法执行剩下的程序
只看楼主
feige3721
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-4-9
结帖率:0
已结贴  问题点数:20 回复次数:5 
【求助】dataAdapt填充指令执行时自动退出,无法执行剩下的程序
这是一个按钮触发后的指令。调试的时候发现的问题,本来想生成一个矩阵的。为什么运行到fill那就突然返回了?
还有就是最后四行什么用,是不是对生成的矩阵重新构成一个新的矩阵?最后两行的0和1代表什么意思?
请不吝赐教,谢谢
if (radioButton2.Checked)
                {   Int32 selectedRowCount = checkedListBox1.SelectedItems.Count;
                    string fields = "";
                    if (selectedRowCount > 0)
                    {
                        for (int b = 0; b < checkedListBox1.CheckedItems.Count; b++)
                        {
                            fields += "," + ee[b];
                        }
                        fields = fields.Substring(1);
                    }
                    ArrayList myarraylist = new ArrayList();
                    string conStr = "user id=system;password=manager;data source=oradb";
                    OracleConnection con = new OracleConnection(conStr);
                    con.Open();
                    DataSet myset1 = new DataSet();
                    DataTable mytable1 = new DataTable();
                    string pici1_select = "select " + fields + " from HISTORY." + biao + " where sampleTime>=20 and sampleTime<=60";
                    OracleDataAdapter myadapter1 = new OracleDataAdapter(pici1_select, con);
                    myadapter1.Fill(myset1, "database");//到这就截止了,下面的程序还没执行就自动返回了,这行程序貌似也没执行成功,因为断点运行时箭头直接没指到下一行就返回了。
                    double[,] data1 = new double[myset1.Tables[0].Rows.Count, myset1.Tables[0].Columns.Count];
                    for (int a = 0; a < myset1.Tables[0].Rows.Count; a++)
                        for (int b = 0; b < myset1.Tables[0].Columns.Count; b++)
                        {
                            data1[a, b] = Convert.ToDouble(myset1.Tables[0].Rows[a][b]);

                        }
                    string jjstr1 = tonewstrings(data1);
                    myarraylist.Add(jjstr1);
                    myarraylist.Add(data1.GetLength(0));
                    myarraylist.Add(data1.GetLength(1));
搜索更多相关主题的帖子: dataAdapt 指令 自动 
2010-09-07 11:02
saitor
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:5
帖 子:373
专家分:1520
注 册:2009-5-18
得分:0 
database你数据库表叫这名字?
2010-09-07 11:19
feige3721
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-4-9
得分:0 
再附上一个我运行正确的一段相似程序作参考,这段指令可以完全执行,fill填充那没有出现问题
if (selectedRowCount > 0)
                {
                    for (int b = 0; b < checkedListBox1.CheckedItems.Count; b++)
                    {
                        fields += "," + ee[b];
                    }
                    fields = fields.Substring(1);
                    string conStr = "user id=system;password=manager;data source=oradb";
                    OracleConnection con = new OracleConnection(conStr);
                    con.Open();
                    DataSet myset = new DataSet();
                    DataTable mytable = new DataTable();

                    string selectstr = "select " + fields + " from HISTORY." + biao;     
                    OracleDataAdapter myadapter = new OracleDataAdapter(selectstr, con);
                    myadapter.Fill(myset, "database");
                    double[,] data = new double[dataGridView1.SelectedRows.Count, myset.Tables[0].Columns.Count];
                    for (int a = 0; a < dataGridView1.SelectedRows.Count; a++)
                        for (int b = 0; b < myset.Tables[0].Columns.Count; b++)
                        {
                            data[a, b] = Convert.ToDouble(myset.Tables[0].Rows[dataGridView1.SelectedRows[a].Index][b]);
                        }
2010-09-07 11:56
saitor
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:5
帖 子:373
专家分:1520
注 册:2009-5-18
得分:6 
select " + fields + " from HISTORY." + biao + " where sampleTime>=20 and sampleTime<=60
这句到SQL里执行下看看有没有数据
2010-09-07 12:50
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
得分:6 
根据你前后两次的说法判断,好像" where sampleTime>=20 and sampleTime<=60";这里有问题。

我个人建议你使用try...  catch(exception ex)的方法,把exception的提示信息显示出来,这样会帮助你分析哪里出现了问题!!
2010-09-13 08:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-319456-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083934 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved