MS Access查询 [英] MS Access Query

查看:133
本文介绍了MS Access查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public OleDbDataReader SqlFindColomnName(string s2)
{
    con.Close();
    con.Open();           
    cmd = new OleDbCommand("select classname, CASE WHEN 
    subject1 = ''" + s2 + "'' THEN ''subject1'' WHEN 
    subject2 = ''"       +       s2 + "'' THEN ''subject2'' WHEN 
    subject3 = ''" + s2 + "'' THEN ''subject3'' END AS Subject
    from studentregistration", con);
    OleDbDataReader rd = cmd.ExecuteReader();
    return rd; 
}


它给出了这样的错误...
IErrorInfo.GetDescription失败,出现E_FAIL(0x80004005).


it gives an error like this...
IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

推荐答案



当您在查询语句中使用访问保留字时,似乎会发生这种情况.

我怀疑类名"一词可能会造成麻烦.尝试绕一下它.

示例:

选择[classname],CASE .....

请参阅此处以获取更多信息.. [ http://bytes.com/topic/visual-basic-net/answers/353905-ierrorinfo-getdescription-failed-e_fail-0x80004005-为什么-即时通讯]

希望对您有帮助
Hi,

This seems to happen when you use a access reserved word in your query statement.

I suspect the word "classname" which might be creating trouble. Try putting braket around it.

Example:

select [classname], CASE .....

Please refer here for more ..[http://bytes.com/topic/visual-basic-net/answers/353905-ierrorinfo-getdescription-failed-e_fail-0x80004005-why-im-i-getting]

Hope it helps you,


您好,

您的查询有几个问题

大小写的语法可能类似-请查看.
-X =真然后Y结束时的情况
-当X = True然后Y ELSE Z结束时的情况
-X =真然后CASE Y =真然后Z End End

另外,我不确定您可能会考虑使用IIF语句在Access中实现CASE的情况.使用上面的示例,它类似于

-IIF(X = True,Y)
-IIF(X = True,Y,Z)
-IIF(X = True,IIF(Y = True,Z))

希望这对您有所帮助.
Hello there,

Couple of issues with your query

syntax for case could be something like - please review.
- CASE WHEN X=True THEN Y End
- CASE WHEN X=True Then Y ELSE Z End
- CASE WHEN X=True Then Case WHEN Y=True Then Z End End

Also I am not sure how well CASE is implemented in Access you might consider using the IIF statement; using above example, it would be something like

- IIF(X=True, Y)
- IIF(X=True,Y, Z)
- IIF(X=True,IIF(Y=True,Z))

Hope this helps you out.


这篇关于MS Access查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆