create PROCEDURE [dbo].[pro_InsertRecord]
@table varchar(30) ,
@field varchar(max) ,
@value varchar(max)
AS
SET NOCOUNT ON
BEGIN
EXEC('INSERT INTO ' + @table + '(' + @field + ') VALUES ( '+ @value +')')
END
我无法在数据库中插入记录,但收到插入错误消息为“无效列名”
我的代码:
string fieldnames = "Login_UserName, Login_Password, Login_Role_Id";
string fieldvalues = UserName +"','" + Password + "'," + Role ;
com.Common.InsertRecord("Login", fieldnames, fieldvalues);
答案 0 :(得分:0)
而不是
string fieldvalues = UserName +"','" + Password + "'," + Role ;
使用
string fieldvalues = "'" + UserName + "','" + Password + "'," + Role ;