[已解决]当我运行我的Web项目时,会出现三种不同的消息,一种是及时的? [英] [Solved]When i run my web project three different messages appear, one in time ?
问题描述
大家好,
我有该代码:
当我运行我的Web项目时,会出现三种不同的消息,
每一封邮件都会出现一次.
当我运行时,该代码出现消息错误:
Hi every body,
I have that code:
When i run my web project there are three different messages appear,
every message appear in one time.
When i make run, message error appear for that code:
public static int GetNumOfTopicInTable(out int TopicsNum)
{
topicCommand.Connection = connection;
topicCommand.CommandType = CommandType.StoredProcedure;
topicCommand.CommandText = "uspNumOfTopicInTable";
connection.Open();
TopicsNum = Convert.ToInt32(topicCommand.ExecuteScalar());
connection.Close();
return TopicsNum;
}
当呼叫者到达以下那一行时:
when the caller reach to that line of:
connection.Open();
出现此错误:
连接未关闭.连接的当前状态为打开.
虽然是我第一次打开它.
但是,当我关闭VS 2005并再次将其打开并运行时,会出现以下消息:
第9位没有行.
对于该代码:
this error appear:
The connection was not closed. The connection''s current state is open.
Although it is first time i open it.
But when i close VS 2005 and open it again and make run this message appear:
There is no row at position 9.
for that code:
lbtnHomeTopicAddress.Text = topicDataSet.Tables[0].Rows[i]["TopicAddress"].ToString();
当我尝试通过按F11键运行项目时,会出现另一条消息:
过程uspNumOfTopicInTable没有提供参数和参数.
对于该代码:
And when i try to run project by press on F11 this another message appear:
Procedure uspNumOfTopicInTable has no parameters and arguments were supplied.
for that code:
TopicsNum = Convert.ToInt32(topicCommand.ExecuteScalar());
任何人都可以帮助我
OP自己解决了该问题,掩盖为已解决的问题
any one can help me please
OP solved the issue himself & question masked as Solved
推荐答案
只需将其从未答复列表中删除即可.将来可能有人遇到类似的问题,那么这个问题(实际上是OP)可能会有所帮助.
对OP:请用其他人的答案来更新问题-将来可以参考.
Just to remove it from the unanswered list. Might be someone face something similar in future and then this question(OP actually) might help.
To OP: Please do update the question with answer for others - it would help in future to reference.
我找到了解决问题的方法,它是:
第一个问题:
连接未关闭.连接的当前状态为打开.
解决方案:
我用了try..catch ... finally:
I found the solution for my problems and it is that:
first problem:
The connection was not closed. The connection''s current state is open.
solution:
I used try....catch...finally:
try
{
connection.Open();
TopicsNum = Convert.ToInt32(topicCommand.ExecuteScalar());
connection.Close();
}
catch
{
}
finally
{
connection.close();
}
第二个问题:
过程uspNumOfTopicInTable没有提供参数和参数.
解决方案:
我使用了以下代码:
second problem:
Procedure uspNumOfTopicInTable has no parameters and arguments were supplied.
solution:
I used this code:
topicCommand.Parameters.clear();
最后一个问题是与我的代码相关的自定义问题,我根据情况解决了该问题.
谢谢大家
再见
the last problem is custom problem that related to my code and i solved it according to my case.
Thanks every body
bye
这篇关于[已解决]当我运行我的Web项目时,会出现三种不同的消息,一种是及时的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!