Oracle Query无法正常工作

时间:2016-11-16 23:12:00

标签: c# asp.net oracle

我使用C#WebService创建应用程序,我想执行Oracle查询(I tested on SQL Developer and works fine)但是当我尝试执行查询时,它似乎无法执行(我没有收到任何错误消息等等我的连接没关系,我测试了另一个查询并且工作正常)所以也许我认为我的查询并没有被C#完全理解,这是我的DB_Class:

public DataTable TablesConsult(string op)
{
    dt = new DataTable();
    ds = new DataSet();
    string sql = "";
    switch (op)
    {
        case "AllWip":
            sql = @"
SELECT 
    RTRIM(WIP) AS WIP 
FROM
    (SELECT ' ' AS  WIP  
     FROM DUAL 
     UNION 
     SELECT distinct WIP 
     FROM MyTable 
     WHERE LENGTH(RTRIM(WIP))>0 
     ORDER BY 1)";

            break;

    }
    try
    {
        Open();
        OracleDataAdapter da = new OracleDataAdapter(sql, conn);
        da.Fill(ds);
        dt = ds.Tables[0];
    }
    catch (Exception ex)
    {
    }
    finally
    {
        Close();
    }
    return dt;
}

这是我的网络方法:

[WebMethod]
public string ObtenerAllWip()
{
    DataTable dt = new DataTable();
    dt = conn.TablesConsult("AllWip");

    Ticket tic;
    List<Ticket> lista = new List<Ticket>();
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        tic = new Ticket();

        tic.Wip = dt.Rows[i]["WIP"].ToString();
        lista.Add(tic);
        tic = null;
    }
    JavaScriptSerializer js = new JavaScriptSerializer();
    string lineas = js.Serialize(lista);
    return lineas;
}

就像我说的那样我认为my query is wrong (maybe C# doesn't recognize the format or something like that)因为如果我尝试像Select Wip from MyTable这样的东西,那就有效了。我当前的查询出了什么问题?

0 个答案:

没有答案