this.windConnection = new SqlConnection("Server=localhost; User=sa; PWD=111111;database=DFZQ;Asynchronous Processing=true");
this.windConnection.Open();
this.windCommand = this.windConnection.CreateCommand();windCommand.CommandText = "SELECT stockCode,sum(volume) FROM [DFZQ].[dbo].[fundPortfolio] where stopDate='" + tradingDate + "'group by stockCode";
SqlDataReader sdr5 = windCommand.ExecuteReader();
Dictionary<string, double> getSumStockVolume1 = new Dictionary<string, double>();
foreach (KeyValuePair<string, double> pair in getSumStockVolume1)
{
string stockCode = (string)sdr5["stockCode"];
double sumStockVolume1 = (double)sdr5["sum(volume)"];
getSumStockVolume1.Add(stockCode, sumStockVolume1);
}
sdr5.Close();
return getSumStockVolume1;
this.windConnection.Open();
this.windCommand = this.windConnection.CreateCommand();windCommand.CommandText = "SELECT stockCode,sum(volume) FROM [DFZQ].[dbo].[fundPortfolio] where stopDate='" + tradingDate + "'group by stockCode";
SqlDataReader sdr5 = windCommand.ExecuteReader();
Dictionary<string, double> getSumStockVolume1 = new Dictionary<string, double>();
foreach (KeyValuePair<string, double> pair in getSumStockVolume1)
{
string stockCode = (string)sdr5["stockCode"];
double sumStockVolume1 = (double)sdr5["sum(volume)"];
getSumStockVolume1.Add(stockCode, sumStockVolume1);
}
sdr5.Close();
return getSumStockVolume1;
解决方案 »
- 继承自System.ComponentModel.Component转为System.Windows.Forms.Control
- 变量初始化问题
- datagirdview绑定数据到指定列
- 请问:vs2005在vista系统上要安装的2个补丁在哪有的下?
- .net winform里声明的public属性外部为何无法访问?
- 我的VS2005 的 workflow fundation 设计器如何和其它的不同!已经装了最新的了。??急急急,请看详细
- 有工作流资料的兄弟请进
- 请教,做一个cs,用来定时访问一个网站!
- 郁闷,菜鸟问题!请问我能不能在一个空的DataView中新增一行
- 请问什么叫本地线程?
- PictureBox控件,怎么用变量控制其显示的图片!
- 【求助】关于typeof(type)的问题
foreach (KeyValuePair<string, double> pair in getSumStockVolume1)
{}
getSumStockVolume1中没有数据...
foreach (KeyValuePair<string, double> pair in getSumStockVolume1)
{}
getSumStockVolume1是你new出来的,没有数据,为空。
SqlDataReader sdr5 = windCommand.ExecuteReader();
Dictionary<string, double> getSumStockVolume1 = new Dictionary<string, double>();
foreach (sdr5.Read())
{
string stockCode = (string)sdr5["stockCode"];
double sumStockVolume1 = (double)sdr5["sum(volume)"];
getSumStockVolume1.Add(stockCode, sumStockVolume1);
}
SqlDataReader sdr5 = windCommand.ExecuteReader();
Dictionary<string, double> getSumStockVolume1 = new Dictionary<string, double>();
While(sdr5.Read())
{
string stockCode = (string)sdr5["stockCode"];
double sumStockVolume1 = (double)sdr5["sum(volume)"];
getSumStockVolume1.Add(stockCode, sumStockVolume1);
} 这样就把它们放到字典dictionary里去了
{
String stockCode = String.Empty;
if(!sdr5.IsDBNull(0))
{
stockCode = sdr5.GetString(0);
} Int32 sum = -1;
if(!sdr5.IsDBNull(1))
{
stockCode = sdr5.GetInt(1);
} if(!String.IsNullOrEmpty(stockCode)
&& sum >0 )
{
getSumStockVolume1.Add(stockCode, sum);
}
}