简体   繁体   中英

Importing FoxPro tables into SQL using C# - One table works, one doesn't

I'm working some methods to import data from FoxPro tables and write it to SQL tables. This is just a tiny chunk of an enterprise-class application, and frankly most of it is over my head. The method I'm having problems with gets two FoxPro tables and puts them in Datasets. The first table comes over no problem, but the second keeps coming up empty. Here's my code (more details after the code):

public DataSet GetFoxProDelinquencyData()
    {
        DataSet bothDlqTables = new DataSet();
        DataSet DlqData;
        string selectQuery = "SELECT * FROM MasterDlqTable";

        try
        {
            DlqData = _foxProServiceAccess.ExecuteFoxProDataSet(selectQuery, 1);
        }
        catch (Exception exceptionToHandle)
        {
            throw ExceptionHelper.HandleFoxProException(exceptionToHandle,
                            "Failed to get data from FoxPro");
        }

        DlqData.Tables[0].TableName = "Master";
        bothDlqTables.Tables.Add(DlqData.Tables[0].Copy());
        string delqnum = Convert.ToString(bothDlqTables.Tables[0].Rows[0]["delqnum"]);
        selectQuery = String.Format("SELECT * FROM rvdlqhst_txps WHERE delqnum = '{0}'", delqnum);

        try
        {
            DlqData = _foxProServiceAccess.ExecuteFoxProDataSet(selectQuery, 1);
        }
        catch (Exception exceptionToHandle)
        {
            throw ExceptionHelper.HandleFoxProException(exceptionToHandle,
                            "Failed to get data from FoxPro");
        }

        DlqData.Tables[0].TableName = "History";
        bothDlqTables.Tables.Add(DlqData.Tables[0].Copy());
        return bothDlqTables;
    }

So, when I'm debugging and I look at the content of bothDlqTables just before the return at the end, the Master table is perfect, and the History table has the correct columns from its FoxPro equivalent, but it has no data. Same with the DlqData dataset. The delqnum string contains 000210 and our dB guy confirms that the FoxPro table definitely contains records with that delinquency number. When he runs

SELECT * FROM rvdlqhst_txps WHERE delqnum = '000210'

from within the database viewer, he gets results. I've tried hard-coding that SELECT statement as a string instead of the string.format command, and I still get the same empty table. Any suggestions?

UPDATE: I'm also getting an intermittent error on the first query of:

Could not connect to net.tcp://rdsfoxproqa.alatax.com/FoxProService_Dist. The connection attempt lasted for a time span of 00:00:01.0625340. TCP error code 10061: No connection could be made because the target machine actively refused it 172.19.0.105:808.

It happens from time to time, and often I can just wait 30 min or so and then try again and the query works. I don't think this is related, but I also don't know what's causing it and would love to.

If DaveB's answer does not help: if you remove the WHERE clause completely, do you then get some data? That might help towards finding the cause of the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM