我正在使用visual studio 2010和sql Management Studio R2
虽然SQL查询在sql management studio中工作正常.它在视觉工作室中引发了一个例外.超出索引例外,当我编辑进行任何其他调整时,它会抛出格式异常.请帮我.代码如下:
虽然SQL查询在sql management studio中工作正常.它在视觉工作室中引发了一个例外.超出索引例外,当我编辑进行任何其他调整时,它会抛出格式异常.请帮我.代码如下:
string sql = "SELECT disTINCT Year(tdate) FROM saletransaction ORDER BY Year(tdate) DESC"; cmd = new sqlCommand(sql,con); dr = cmd.ExecuteReader(); DateTime dt; while (dr.Read()) { if (dr.HasRows == true) { dt = Convert.ToDateTime(dr["tdate"].ToString()); //tdate is the name of the column (getting an error at this line. ) comboBox1.Items.Add(dt.Year.ToString()); } }
解决方法
原文地址:https://www.jb51.cc/csharp/91552.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。