用DAAB插入数据的时候怎么写?
string cs = ConfigurationSettings.AppSettings[ "SqlServerConnectionString "];
AdoHelper helper = AdoHelper.CreateHelper( "sqlDA ");
protected void Button1_Click(object sender, EventArgs e)
{
IDataParameter[] para = new IDataParameter[3];
para = helper.ExecuteNonQuery( )//这里不知道怎么写了。
para[1].Value = "DFDFSD ";
para[0].Value = "dfgdg ";
para[2].Value = FCKeditor1.Value;
helper.ExecuteNonQuery(cs, System.Data.CommandType.Text, "insert into Employees(LastName,FirstName,safd)values( '{0} ', '{1} ', '{2} ') ", para);
}
帮忙看看。
------解决方案--------------------para = helper.ExecuteNonQuery( )//这里不知道怎么写了。
这里你要做什么?
IDataParameter[] para = new IDataParameter[3]; 貌似不对吧
DAAB的文档里应该有例子的
------解决方案--------------------SqlClient 要用命名参数
IDataParameter[] para = new SqlParameter[] {
new SqlParameter( "@LastName "),
new SqlParameter( "@FisrtName ")
//....
};
para[0].Value = "DFDFSD ";
para[1].Value = "dfgdg ";
//...
helper.ExecuteNonQuery(cs, System.Data.CommandType.Text, "insert into Employees(LastName,FirstName)values(@LastName, @FirstName) ", para);
------解决方案--------------------简单的不用存储过程,直接用sql语句那?
string strTxt=insert into Employees(LastName,FirstName,safd) values( '11 ', '2 ', '3 ');
helper.ExecuteNonQuery(cs, System.Data.CommandType.Text, strTxt);