C# 你用的是;调用Proc_name();直接作为字符串,或在C中使用CommandType.StoredProcess#
问题是:C# 你用的是;调用Proc_name();直接作为字符串,或在C中使用CommandType.StoredProcess#,c#,mysql,stored-procedures,C#,Mysql,Stored Procedures,问题是: 当您从MySQL调用存储过程到C#代码时,您将 字符串[“调用进程名('param1','param2',3)”]直接作为 插入或删除时的类似语句,如下所示: this.command= new MySqlCommand("CALL getAllNamesbyOld(5)", this.conn); this.command.ExecuteReader(); ... this.command = new MySqlCommand("getAllNamesbyOld", this.c
- 当您从MySQL调用存储过程到C#代码时,您将
字符串[“调用进程名('param1','param2',3)”]直接作为
插入或删除时的类似语句,如下所示:
this.command= new MySqlCommand("CALL getAllNamesbyOld(5)", this.conn); this.command.ExecuteReader(); ...
this.command = new MySqlCommand("getAllNamesbyOld", this.conn); this.command.CommandType = CommandType.StoredProcedure;
- 或者你用
select存储过程的MySqlCommand.CommandType,如下所示:
this.command= new MySqlCommand("CALL getAllNamesbyOld(5)", this.conn); this.command.ExecuteReader(); ...
this.command = new MySqlCommand("getAllNamesbyOld", this.conn); this.command.CommandType = CommandType.StoredProcedure;
那么使用哪一个呢???使用
CommandType.StoredProcess
更快
使用CommandType.storedProcess时,您将是参数化它的人,并将为数据库保存一些工作
当使用第一个选项时,MySQL将进行参数化 在很大程度上,大多数人会争辩说,也应该使用第一个参数。。