大家好,我在sqldbtype中的这段代码有问题,我不知道为什么,虽然没有什么问题,你能帮我发现这个问题吗?
抱歉,附加图片从外部链接,因为我是新的堆栈溢出,这需要一个声誉来附加图像。诚挚的问候
http://www.iraqi-up.com/uploads/13952507661.png
public static int inserforum(int Title_id, string Question, string Post_name, DateTime Date_time)
{
int rowsAffected = 0;
using (SqlConnection connection = ConnectionManager.GetDatabaseConnection())
{
SqlCommand command= new SqlCommand ("inserforum", connection) ;
command.CommandType=CommandType.StoredProcedure;
command.Parameters.Add("@Title_id",sqlDbType.Int).value=Title_id;
command.Parameters.Add("Question",sqlDbType.varChar).value=Question;
command.Parameters.Add("Post_name",sqlDbType.varChar).value=Post_name;
command.Parameters.Add("Date_time",sqlDbType.DateTime).value=Date_time;
rowsAffected=command.EndExecuteNonQuery();
}
return rowsAffected;
}}发布于 2014-03-20 01:33:13
它是"SqlDbType",不是"sqlDbType“。C#区分大小写,你不能像在其他语言中那样随意使用小写和大写。
此外,您还希望使用不是Begin或End方法的非查询方法。
rowsAffected = command.ExecuteNonQuery();
使用它的Begin/End版本用于异步执行查询,这在某些情况下很有用,但在很多情况下不是很有用。
https://stackoverflow.com/questions/22513708
复制相似问题