vb.net - 无法使用 oracledataadpter 填充数据集

标签 vb.net oracle ado.net

我遇到了一个非常奇怪的问题,我正在使用下面的一段代码,但是 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

最佳答案

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

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

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

关于vb.net - 无法使用 oracledataadpter 填充数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15337775/

相关文章:

vb.net - 针对 Access 数据库的 Update 语句中的语法错误(使用 OleDbCommandBuilder)

c# - 有没有办法在 VB.NET 中实现类似 Caliburn 的协程,因为没有 yield 关键字

sql - 如何处理将 DBNull 传递给函数?

java - Oracle nvl 需要将 null 插入数字字段

c# - 一个异常两条消息

entity-framework - 首先在EF 4.1代码中映射关联表

vb.net - 创建 UdpClient 来读取传入数据 - VB.net

java - 如何在 Hibernate 和 Oracle 中使用命名查询将字符串作为数字进行搜索?

mysql - 在 PL SQL 中验证数据库级别的列

entity-framework - ADO.NET Entity Framework : Can I have multiple entity types for the same row