3

我面临一个非常奇怪的问题,我正在使用以下代码,但 有时ds没有填充ds中有数据但并非总是如此,我已经更改了连接池并重新启动了iis,但完全没有运气,我我无法找到问题所在,请帮帮我。我在TOAD中运行相同的查询及其给出的结果,如果有任何不一致的事情,我也提交了事务。

 Dim command As New OracleCommand
        Dim ds As New DataSet
        Try
            Using connection As New OracleConnection
(ConfigurationManager.ConnectionStrings("CA").ConnectionString.ToString())
                connection.Open()
                command.Connection = connection
                command.CommandText = "SELECT w.portfolio, w.appl_group,
tm.trng_title, p.tt_program_title," & _
                                     " p.created_date,
p.tt_target_completion_date, p.tt_prog_status," & _
                                     " w.emp_id, w.first_name || ' ' ||
w.last_name, ('Y') training_done_flag," & _
                                     "         t.actual_completion_date,
p.created_by, w.people_manager, " & _
                                     "        w.project_manager, w.flag" &
_
                                    " FROM tt_training_done_records t," & _
                                     "    wsr_employee w, " & _
                                     "   tt_training_master  tm, " & _
                                    "  tt_newprogram p" & _
                                    " WHERE(w.emp_id = t.employee_id)" & _
                                    " AND t.training_info_id = tm.trng_id"
& _
                                    " AND p.tt_program_id(+) =
t.program_id" & _
                                    " AND tm.trng_id IN ( 'TT_009' ) " & _
                                    " AND t.actual_completion_date BETWEEN
TO_DATE('11-Mar-2009')  AND TO_DATE('11-Mar-2013') " & _
                                    " "

                Dim adpt As New OracleDataAdapter(command)
                adpt.AcceptChangesDuringFill = False
                adpt.Fill(ds)
                connection.Close()
            End Using
4

1 回答 1

1

不要依赖将字符串转换为日期的默认行为。使用日期文字或提供格式字符串参数。这引入了对您的 .NET 代码不应依赖的 NLS 环境设置的依赖。

代替TO_DATE('11-Mar-2013')

尝试date '2013-03-11'TO_DATE('11-Mar-2013'), 'DD-Mon-YYYY')

于 2013-05-03T21:12:03.460 回答