帮我,【为您冲话费】您们好,遇到难题了,表单多条数据,插入不成功,变成逗号相连在一个字段了,今天坐等5小时
//添加产品
protected void cmdAdd_Click(object sender, EventArgs e)
{
_waresmodel.会员 = _model.UserId;
_waresmodel.公司名称 = txtgsmcName.Text;
_waresmodel.产品 = txtcpVariety.Text.Trim();
//判断是否为修改状态
if (_isfabu)
{
Javascript.alert(SQLWare.SQLku.Add(_waresmodel) > 0 ? "添加成功!" : "失败,请重试!");
}
else
{
}
}
//这是接数据库的
namespace SQLWare
{
using System;
using System.Data;
using System.Data.SqlClient;
public class SQLku
{
public static int Add(ModelWare.ModelWares model)
{
SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@UserID", SqlDbType.VarChar, 20), new SqlParameter("@gsmc", SqlDbType.NVarChar, 50), new SqlParameter("@cp", SqlDbType.VarChar, 50)};
commandParameters[0].Value = model.会员;
commandParameters[1].Value = model.公司名称;
commandParameters[2].Value = model.产品;
return SqlHelper.ExecuteNonQuery(ConnString.Waresconn, CommandType.StoredProcedure, "[dbo].[Add数据库]", commandParameters);
}
}
//这是数据库的存储过程
ALTER PROCEDURE [dbo].[Add数据库]
DECLARE @i int
Set @i = 0
--开始循环插入数据;
WHILE @i < 3
BEGIN
Set @i =@i +1
INSERT INTO dbo.产品库
(ID, UserID1, gsmc1, cp1)
VALUES
(NEWID(), @UserID, @gsmc, @cp);
END
END
------解决方案--------------------
ALTER PROCEDURE [dbo].[Add数据库]
(@UserID varchar(200), @gsmc varchar(200), @cp varchar(200)) &nbs