这个项目是一个.net项目,用的是vs2013 ,Dapper版本是1.38。奇怪的是在另一个小测试项目中执行是没问题的,关键是在我这个正式的项目里执行出问题啊。
以下是关键代码和截图,请求各位帮助!!!
test te = new test
{
name = "fyw",
id = 1
};
const string str1 = @"update test set name = @name where id = @id;";
using (MySqlConnection conn = OpenConnection())
{
//var execute = conn.Execute(str1, new { id = 1,name = "ww" });//这条语句是可以的,没有问题
var execute = conn.Execute(str1, te);//这一条语句总是出问题
}
详细信息如下:
未处理MySql.Data.MySqlClient.MySqlException
HResult=-2147467259
Message=Fatal error encountered during command execution.
Source=MySql.Data
ErrorCode=-2147467259
Number=0
StackTrace:
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
在 Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) 位置 d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:行号 3310
在 Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) 位置 d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:行号 1310
在 Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable`1 commandTimeout, Nullable`1 commandType) 位置 d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:行号 1185
在 SmartMining.Program.Main(String[] args)
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException: MySql.Data.MySqlClient.MySqlException
HResult=-2147467259
Message=Parameter '@name' must be defined.
Source=MySql.Data
ErrorCode=-2147467259
Number=0
StackTrace:
在 MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
在 MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
在 MySql.Data.MySqlClient.Statement.BindParameters()
在 MySql.Data.MySqlClient.Statement.Execute()
在 MySql.Data.MySqlClient.PreparableStatement.Execute()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
InnerException:
有点着急,迫切请求各位支援啊!!!