Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using .net core 2.2 and some users having this problem:

My API code is below:

var dt = ktd.LIST_VC_TUITHU_NOUSE_BCS(data.loai_taikien, data.noi_den, data.ma_tuithu, user.ma_buucuc, user.userid);
                List<object> lstBK = new List<object>();
                if (dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var bk = new
                        {
                            id_tuithu = dt.Rows[i]["ID_TUITHU"].ToString(),
                            ma_tuithu = dt.Rows[i]["MA_TUITHU"].ToString(),
                            loai_tt = dt.Rows[i]["LOAI_TT"].ToString(),
                            chuyenxe_den = dt.Rows[i]["CHUYENXE_DEN"].ToString(),
                            loai_nhap_xuat = dt.Rows[i]["LOAI_NHAP_XUAT"].ToString(),
                            trang_thai = dt.Rows[i]["TRANG_THAI"].ToString(),
                            ma_buucuc_di = dt.Rows[i]["MA_BUUCUC_DI"].ToString(),
                            ma_buucuc_den = dt.Rows[i]["MA_BUUCUC_DEN"].ToString(),
                            ma_buucuc = dt.Rows[i]["MA_BUUCUC"].ToString(),
                            ma_chuyenthu = dt.Rows[i]["MA_CHUYENTHU"].ToString(),
                            so_luong = dt.Rows[i]["SO_LUONG"].ToString(),
                            trong_luong = dt.Rows[i]["TRONG_LUONG"].ToString(),
                            ghi_chu = dt.Rows[i]["GHI_CHU"].ToString(),
                            ngay_nhap_may = dt.Rows[i]["NGAY_NHAP_MAY"].ToString(),
                            nguoi_nhap_may = dt.Rows[i]["NGUOI_NHAP_MAY"].ToString(),
                            id_chuyenthu = dt.Rows[i]["ID_CHUYENTHU"].ToString(),
                            stt = dt.Rows[i]["STT"].ToString(),
                            username = dt.Rows[i]["USERNAME"].ToString(),
                            loai_hang_hoa = dt.Rows[i]["LOAI_HANG_HOA"].ToString(),
                            loai_dichvu = dt.Rows[i]["LOAI_DICHVU"].ToString(),
                            loai_hh = dt.Rows[i]["LOAI_HH"].ToString(),
                            vung_di = dt.Rows[i]["VUNG_DI"].ToString(),
                            vung_den = dt.Rows[i]["VUNG_DEN"].ToString(),
                            ten_tinh_den = dt.Rows[i]["TEN_TINH_DEN"].ToString(),
                            ma_tinh_den = dt.Rows[i]["MA_TINH_DEN"].ToString(),
                        };
                        lstBK.Add(bk);
                    }
                }


In Oracle DB, I had it returned all columns with names I defined.
And it works normally with most of users. Only some users tell me they got this annoying "Specified cast is not valid" message.

What I have tried:

I asked an user for his account information and query the data that my API calls to OracleDB. And as I thought, data was there. All DB columns' names match my API's requirement. I cannot debug the API in the production environment and cannot export data to the development environment to debug, too.
Could anyone helps me with this problem ?
Posted
Updated 1-Dec-22 2:01am
v2
Comments
Richard MacCutchan 1-Dec-22 5:19am    
You need to find out where that message is coming from. No one here can possibly guess.

1 solution

We don't know the datatypes for any of those variables, and we have no idea where in that code you are getting the error - so we can't directly help you.

So the first thing to do is to add a try...catch block to your code, and log the exception and all it's details to a log file the user can send to you when it goes wrong. I'd also suggest logging the whole row of data involved at thee same time.

When you get the file, you can look at exactly where in the code your exception happened, and what data it was processing - which should start to give you clues as to why it is happening at all, and why it might be a problem for some (but not all) users.

If the same data works for userA but fails for userB, then it's probably a compatibility problem (numeric or date format, something like that) so it's probably work logging the users Locale info at the same time.

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900