简体   繁体   中英

SQL Query doesn't work in asmx web service

I made asmx web, to get data from oracle database. It works fine when I use a short query:

select * from dbrepn10.DDT_DA_DIRECTION_SV

But if I use long query like this:

SELECT XB_.R_OBJECT_ID, XB_.OBJECT_NAME, XB_.R_CREATION_DATE, XB_.R_MODIFY_DATE, XB_.R_MODIFIER, XB_.R_ACCESS_DATE, XB_.A_CONTENT_TYPE, 
    XB_.R_CONTENT_SIZE, XB_.OWNER_NAME, XB_.ACL_DOMAIN, XB_.ACL_NAME, XB_.R_CREATOR_NAME, BKB_.DSI_PAGE_COUNT, EKB_.DSS_REG_NUMBER, EKB_.DST_REG_DATE, EKB_.DSS_OBJECT_NAME_RU, MKB_.DSS_TITLE_RU, MKB_.DSS_TITLE_KK 
FROM dbrep36.DM_SYSOBJECT_S XB_, dbrep36.DDT_EAR_S BKB_, dbrep36.DDT_EAR_REG_S EKB_,dbrep36.DDT_DA_DIRECTION_S MKB_ 
WHERE (XB_.R_OBJECT_ID=MKB_.R_OBJECT_ID AND (XB_.R_OBJECT_ID=BKB_.R_OBJECT_ID AND (BKB_.R_OBJECT_ID=MKB_.R_OBJECT_ID AND (XB_.R_OBJECT_ID=EKB_.R_OBJECT_ID AND(BKB_.R_OBJECT_ID=EKB_.R_OBJECT_ID AND EKB_.R_OBJECT_ID=MKB_.R_OBJECT_ID)))))

My web service doesn't return a result. And there are no error messages.

What could be the reason ?

Code:

 public DataTable GetSpecificView(string query_string)
    {
        string host = WebConfigurationManager.AppSettings["host"].ToString();
        string port = WebConfigurationManager.AppSettings["port"].ToString();
        string servicename = WebConfigurationManager.AppSettings["servicename"].ToString();
        string user = WebConfigurationManager.AppSettings["user"].ToString();
        string password = WebConfigurationManager.AppSettings["password"].ToString();

        DataTable data = new DataTable();

        string connectionString = OracleConnString(host, port, servicename, user, password);
        OracleConnection con = new OracleConnection(connectionString);
        con.ConnectionString = connectionString;
        string result = "";
        try
        {
            con.Open();
            OracleCommand cmd = new OracleCommand(query_string, con);

            DataSet dataSet = new DataSet();
            new OracleDataAdapter(cmd).Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                data = dataSet.Tables[0];
            }
            con.Close();

        }
        catch (Exception ex)
        {
            result = ex.Message;
        }
        return data;
    }

Are you certain you are not getting an exception? Your catch loop isn't doing anything, it's just assigning the exception message to a string which doesn't appear to be logged anywhere.

Also, you should place the con.Close() call in a finally block as it won't be called if an exception is thrown.

Have you tried running your SQL query on the database correctly to make sure it actually works?

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