所以我在C#
中有一个程序从第三方程序访问旧的Firebird 1.5
数据库。我所拥有的方法之一是通过id获取报价或项目的数据:(抱歉那里有一些葡萄牙语单词)
public static List<object> GetFollowUpData(int id, TipoFollowUp tipo)
{
var res = new List<object>();
string q = tipo == TipoFollowUp.Orcamento
? "SELECT ('Q-' || c.CLIENT_CODE || q.CQUO_FNUMB) as Codigo, q.CQUO_NAME as Nome, q.CQUO_SENT as Data, q.CQUO_TOTAL as Total, c.CLIENT_NAME as Empresa, m.CCON_NAME as Contacto, ((CASE WHEN m.CCON_PHONE1 IS null then '' else m.CCON_PHONE1 end) || '/' || (CASE WHEN m.CCON_PHONE2 IS null then '' else m.CCON_PHONE2 end) || '/' || (CASE WHEN m.CCON_PHONE3 IS null then '' else m.CCON_PHONE3 end) || '/' || (CASE WHEN m.CCON_PHONE4 IS null then '' else m.CCON_PHONE4 end) || '/' || (CASE WHEN c.CLIENT_PHONE1 IS null then '' else c.CLIENT_PHONE1 end) || '/' || (CASE WHEN c.CLIENT_PHONE2 IS null then '' else c.CLIENT_PHONE2 end) || '/' || (CASE WHEN c.CLIENT_PHONE3 IS null then '' else c.CLIENT_PHONE3 end) || '/' || (CASE WHEN c.CLIENT_PHONE4 IS null then '' else c.CLIENT_PHONE4 end)) as Telefones FROM CMULTIQUOTES q, CLIENTS c, CCONTACTS m WHERE q.ID = @id AND c.CLIENT_ID = q.CLIENT_ID AND q.CLIENT_PM = m.CCON_ID"
: "SELECT q.PROJ_CODE as Codigo, q.PROJ_NAME as Nome, q.PROJ_COMPLETED as Data, (select sum(j.CJOB_TOTAL) from CJOBS j where j.PROJ_ID = @id) as Total, c.CLIENT_NAME as Empresa, m.CCON_NAME as Contacto, ((CASE WHEN m.CCON_PHONE1 IS null then '' else m.CCON_PHONE1 end) || '/' || (CASE WHEN m.CCON_PHONE2 IS null then '' else m.CCON_PHONE2 end) || '/' || (CASE WHEN m.CCON_PHONE3 IS null then '' else m.CCON_PHONE3 end) || '/' || (CASE WHEN m.CCON_PHONE4 IS null then '' else m.CCON_PHONE4 end) || '/' || (CASE WHEN c.CLIENT_PHONE1 IS null then '' else c.CLIENT_PHONE1 end) || '/' || (CASE WHEN c.CLIENT_PHONE2 IS null then '' else c.CLIENT_PHONE2 end) || '/' || (CASE WHEN c.CLIENT_PHONE3 IS null then '' else c.CLIENT_PHONE3 end) || '/' || (CASE WHEN c.CLIENT_PHONE4 IS null then '' else c.CLIENT_PHONE4 end)) as Telefones FROM PROJECTS q, CLIENTS c, CCONTACTS m WHERE q.PROJ_ID = @id AND c.CLIENT_ID = q.CLIENT_ID AND q.CLIENT_PM = m.CCON_ID";
using (var cmd = new FbCommand(q) {CommandType = CommandType.StoredProcedure})
using (cmd.Connection = new FbConnection(ConnectionString))
{
cmd.Connection.Open();
cmd.Parameters.Add("@id", id);
using (FbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
res.Add(id); // ID
res.Add(reader[0]); // Código
res.Add(reader[1]); // Nome
res.Add(reader[2]); // Data
res.Add(reader[3]); // Total
res.Add(reader[4]); // Empresa
res.Add(reader[5]); // Contacto
res.Add(reader[6]); // Telefones
res.Add(tipo); // Tipo
}
reader.Close();
}
cmd.Connection.Close();
}
return res;
}
这大部分时间都有效 - 但对于特定项目,它不会返回任何数据(项目编号8771)
我将第二个查询复制粘贴到FlameRobin中,将其连接到数据库并用8771替换查询中的@id,flameRobin返回我想要的数据。
因此,如果FlameRobin可以使用我的查询获取数据,为什么我的程序也不能获得它?
在上面的My方法中,Reader.Read()
imediatly返回false,并且我没有从该项目的数据库中获取数据。到目前为止,其他项目和报价在我检测到的情况下没有问题返回数据
有人有什么想法吗?
答案 0 :(得分:0)
对不起大家 只花了半个小时左右,最后弄清楚我在程序中使用我的开发/测试数据库副本(在VS下)并连接到FlameRobin中的生产副本。
tw数据库之间缺乏同步导致了这个
有问题的项目存在于生产副本中 - 因此FlameRobin正在展示它 - 但不是在程序使用的开发/测试副本中
抱歉