C
Ctal
I've got a simple winform app that populates a datagrid on load. There
are some text boxes on the form where users can add, delete or modify
the grid. I'm using a data adapter to fill the grid and update the
database. I've created stored procedures for select, insert, update,
and delete.
When I try to write data back to the database, I get the error
mentioned in the title. I ran a trace with SQL profiler and it appears
my app is sending double the # of params I need. Not sure how this is
happening. Here's my code.
Insert sproc:
ALTER PROCEDURE [dbo].[usp_AddSignCon]
@Account varchar(255) = '',
@ReverseSign char(1) = 'Y',
@ModifiedBy varchar(255) = 'System',
@RuleStatus char(1) = 'Y'
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO dbo.AddSignCon
(Account, ReverseSign, ModifiedBy, RuleStatus)
VALUES
(@Account, @ReverseSign, @ModifiedBy, @RuleStatus)
Method to Update:
public void UpdateDataSetDA(DataSet dataSet, string sourceTable)
{
DA.InsertCommand=new SqlCommand();
DA.InsertCommand.Connection=CN;
DA.InsertCommand.CommandType = CommandType.StoredProcedure;
DA.InsertCommand.CommandText = "dbo.usp_AddSignCon";
DA.InsertCommand.Parameters.Clear();
DA.InsertCommand.Parameters.Add(new
SqlParameter("@Account",
SqlDbType.VarChar, 255, "Account"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ReverseSign",
SqlDbType.Char, 1, "ReverseSign"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ModifiedBy",
SqlDbType.VarChar, 255, "ModifiedBy"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@RuleStatus",
SqlDbType.Char, 1, "RuleStatus"));
//Snipped code that updates and deletes
DA.Update(dataSet.Tables[sourceTable]);
}
It's bombing on the last line and like I saw with profiler, it appears
to be sending the parameters twice. So I'm sending 8 instead of 4.
Here's my sample trace:
exec dbo.usp_AddSignCon
@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y',@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y'
Thanks in advance for any help
are some text boxes on the form where users can add, delete or modify
the grid. I'm using a data adapter to fill the grid and update the
database. I've created stored procedures for select, insert, update,
and delete.
When I try to write data back to the database, I get the error
mentioned in the title. I ran a trace with SQL profiler and it appears
my app is sending double the # of params I need. Not sure how this is
happening. Here's my code.
Insert sproc:
ALTER PROCEDURE [dbo].[usp_AddSignCon]
@Account varchar(255) = '',
@ReverseSign char(1) = 'Y',
@ModifiedBy varchar(255) = 'System',
@RuleStatus char(1) = 'Y'
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO dbo.AddSignCon
(Account, ReverseSign, ModifiedBy, RuleStatus)
VALUES
(@Account, @ReverseSign, @ModifiedBy, @RuleStatus)
Method to Update:
public void UpdateDataSetDA(DataSet dataSet, string sourceTable)
{
DA.InsertCommand=new SqlCommand();
DA.InsertCommand.Connection=CN;
DA.InsertCommand.CommandType = CommandType.StoredProcedure;
DA.InsertCommand.CommandText = "dbo.usp_AddSignCon";
DA.InsertCommand.Parameters.Clear();
DA.InsertCommand.Parameters.Add(new
SqlParameter("@Account",
SqlDbType.VarChar, 255, "Account"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ReverseSign",
SqlDbType.Char, 1, "ReverseSign"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ModifiedBy",
SqlDbType.VarChar, 255, "ModifiedBy"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@RuleStatus",
SqlDbType.Char, 1, "RuleStatus"));
//Snipped code that updates and deletes
DA.Update(dataSet.Tables[sourceTable]);
}
It's bombing on the last line and like I saw with profiler, it appears
to be sending the parameters twice. So I'm sending 8 instead of 4.
Here's my sample trace:
exec dbo.usp_AddSignCon
@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y',@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y'
Thanks in advance for any help