从Oracle数据库验证检查

从Oracle数据库验证检查

本文介绍了从Oracle数据库验证检查导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查我是否已经输入的数据在我的数据库,但我发现困难做到这一点。下面是我使用的后端,中间层和前端我的code。任何人都可以请检查什么,我做错了。非常感谢您的帮助。

迈克

这是后端code

 公共静态布尔isImported(串号)
    {
        DatabaseAdapter的dba = DatabaseAdapter.GetInstance();
        字符串的SQLQuery =SELECT * FROM FCR.LOAD_CONTROL+
                          WHE​​RE LOAD_DATE = TO_DATE('+日期+,DD / MM / YYYY');

        数据表DT =新的DataTable();
        dt.Load(dba.QueryDatabase(SqlQuery类));

        如果(dt.Rows.Count大于0)

        {
            返回true;
        }
        其他
        {
            返回false;
        }
    }
 

这是业务逻辑code

 公共静态布尔isImported(串号)

    {
        返回DatabaseHandler.isImported(日期);
    }
 

这是前端code

 如果(BusinessLayerHandler.isImported(dateField.Text)==假)

            {
                尝试

                {
                    BusinessLayerHandler.ImportFromOrion(dateField.Text);
                    警报(进口);
                }
                赶上(例外前)
                {
                    警报(不导入);
                }
            }
 

解决方案

贵负荷日期包含时间....如果是的话,你需要截断您的负载时间将其删除: TRUNC( LOAD_DATE)

I am trying to check if I have already imported data inside my database but I am finding difficulties to do this. Below is my code which I am using in backend, middle layer and front end. Can anyone please check to see what I am doing wrong. Thanks alot for your help.

Mike

This is the backend code

public static Boolean isImported(string date)
    {
        DatabaseAdapter dba = DatabaseAdapter.GetInstance();
        string sqlQuery = "SELECT * FROM FCR.LOAD_CONTROL " +
                          "WHERE LOAD_DATE = to_date('" + date + "', 'dd/mm/yyyy') ";

        DataTable dt = new DataTable();
        dt.Load(dba.QueryDatabase(sqlQuery));

        if (dt.Rows.Count > 0)

        {
            return true;
        }
        else
        {
            return false;
        }
    }

This is the business logic code

public static Boolean isImported(string date)

    {
        return DatabaseHandler.isImported(date);
    }

This is the front end code

if(BusinessLayerHandler.isImported(dateField.Text) == false)

            {
                try

                {
                    BusinessLayerHandler.ImportFromOrion(dateField.Text);
                    Alert("Imported");
                }
                catch (Exception ex)
                {
                    Alert("Not Imported");
                }
            }
解决方案

Does your load date contain time ?....if it does you need to truncate your load date to remove it: TRUNC(LOAD_DATE)

这篇关于从Oracle数据库验证检查导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 09:07