我的SQL查询命名样式是错误的吗?
问题描述:
我建立了一个asp.net网站,有时会说未指定错误,有时会发生,并非总是如此:
I build a asp.net website, sometimes it says "Unspecified error", it happens sometimes, not always:
string query = "SELECT TOP 1 * FROM AboutUs";
var reade = AccessHelper.GetReader(query); // Unspecified error occurs here
reader.Read();
// ..read things
DataSet data = AccessHelper.GetDataSet(narstr);
Repeater1.DataSource = data;
有人说我使用保留的关键字,如查询和读者,似乎如果我将变量名更改为其他内容,网站将好好的。但我不认为这是问题,
我没有使用查询,读者处于SQL状态。
我认为问题是我忘了使用某处的Close()方法。
我想知道上面的代码是否有命名问题。
some people say that I use the reserved keywords like query, and reader, It seems that if I change the variable name to something else, the website will wrok properly. But I don't think this is the problem,
I didn't use the query, reader in the SQL statemtent.
I think the problem is that I forget use Close() method somewhere.
I want to know the code above whether has naming problem.
答
我没有得到你的完整代码所以不确定为什么会出现这个错误,但这肯定是,这不是命名风格相关的问题。使用try catch块来获取确切的错误消息。
I am not getting your full code so not sure why this error coming but this is for sure that, this is not a naming style related problem. Use a try catch block to get the exact error message.