Can we use SqlDataAdapter.InsertCommand or Delete, Uptade command with
stored procedure ?

For example:

if i use this code then I get a error message

Procedure :

CREATE PROCEDURE SpDeneme AS
DECLARE @Alan1 int
INSERT INTO TblDeneme (Alan1) VALUES (@Alan1)
GO

Code:

SqlCommand oCmdInsert = new SqlCommand();
oCmdInsert.Connection = Db.CNN;
oCmdInsert.CommandType = CommandType.Text ;
oCmdInsert.CommandType = CommandType.StoredProcedure;
oCmdInsert.CommandText = "SpDeneme";
oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
oAdp.InsertCommand = oCmdInsert;
oAdp.Update(oTbl);


But if I use this code then all is ok. I use here CommandType.Text

SqlCommand oCmdInsert = new SqlCommand();
oCmdInsert.Connection = Db.CNN;
oCmdInsert.CommandType = CommandType.Text ;
oCmdInsert.CommandText = "INSERT INTO TblDeneme (Alan1) VALUES (@Alan1)";
oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
oAdp.InsertCommand = oCmdInsert;
oAdp.Update(oTbl);




GD...

Re: SqlDataAdapter & Stored Procedure by Bilizbo

Bilizbo
Thu Aug 19 13:09:13 CDT 2004

Message is:
"Procedure has no parameters and arguments were supplied"

I think, SqlDataAdapter.Update function can't give the value to the
parameter.


GD...





"HiltonG" <HiltonG@discussions.microsoft.com> wrote in message
news:3D588803-2248-4C0E-998C-365F82D99A12@microsoft.com...
> What is the error message?
>
> I notice that your stored proc code has:
> oCmdInsert.CommandType = CommandType.Text ;
> oCmdInsert.CommandType = CommandType.StoredProcedure;
>
> try removing here
> oCmdInsert.CommandType = CommandType.Text ;
>
> "Gurkan" wrote:
>
> > Can we use SqlDataAdapter.InsertCommand or Delete, Uptade command with
> > stored procedure ?
> >
> > For example:
> >
> > if i use this code then I get a error message
> >
> > Procedure :
> >
> > CREATE PROCEDURE SpDeneme AS
> > DECLARE @Alan1 int
> > INSERT INTO TblDeneme (Alan1) VALUES (@Alan1)
> > GO
> >
> > Code:
> >
> > SqlCommand oCmdInsert = new SqlCommand();
> > oCmdInsert.Connection = Db.CNN;
> > oCmdInsert.CommandType = CommandType.Text ;
> > oCmdInsert.CommandType = CommandType.StoredProcedure;
> > oCmdInsert.CommandText = "SpDeneme";
> > oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
> > oAdp.InsertCommand = oCmdInsert;
> > oAdp.Update(oTbl);
> >
> >
> > But if I use this code then all is ok. I use here CommandType.Text
> >
> > SqlCommand oCmdInsert = new SqlCommand();
> > oCmdInsert.Connection = Db.CNN;
> > oCmdInsert.CommandType = CommandType.Text ;
> > oCmdInsert.CommandText = "INSERT INTO TblDeneme (Alan1) VALUES
(@Alan1)";
> > oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
> > oAdp.InsertCommand = oCmdInsert;
> > oAdp.Update(oTbl);
> >
> >
> >
> >
> > GD...
> >
> >
> >
> >
> >



Re: SqlDataAdapter & Stored Procedure by Gurkan

Gurkan
Fri Aug 20 01:51:46 CDT 2004

I found the answer. I used onyl declaration, not parameter. Correct code is
like that:

CREATE PROCEDURE SpDeneme @Alan1 int
AS
INSERT INTO TblDeneme (Alan1) VALUES (@Alan1)
GO


Thk for answer
microsoft.public.tr.dotnet
Ozgur Yaþar



GD...





"Bilizbo" <yok> wrote in message
news:eWcEjehhEHA.356@tk2msftngp13.phx.gbl...
> Message is:
> "Procedure has no parameters and arguments were supplied"
>
> I think, SqlDataAdapter.Update function can't give the value to the
> parameter.
>
>
> GD...
>
>
>
>
>
> "HiltonG" <HiltonG@discussions.microsoft.com> wrote in message
> news:3D588803-2248-4C0E-998C-365F82D99A12@microsoft.com...
> > What is the error message?
> >
> > I notice that your stored proc code has:
> > oCmdInsert.CommandType = CommandType.Text ;
> > oCmdInsert.CommandType = CommandType.StoredProcedure;
> >
> > try removing here
> > oCmdInsert.CommandType = CommandType.Text ;
> >
> > "Gurkan" wrote:
> >
> > > Can we use SqlDataAdapter.InsertCommand or Delete, Uptade command with
> > > stored procedure ?
> > >
> > > For example:
> > >
> > > if i use this code then I get a error message
> > >
> > > Procedure :
> > >
> > > CREATE PROCEDURE SpDeneme AS
> > > DECLARE @Alan1 int
> > > INSERT INTO TblDeneme (Alan1) VALUES (@Alan1)
> > > GO
> > >
> > > Code:
> > >
> > > SqlCommand oCmdInsert = new SqlCommand();
> > > oCmdInsert.Connection = Db.CNN;
> > > oCmdInsert.CommandType = CommandType.Text ;
> > > oCmdInsert.CommandType = CommandType.StoredProcedure;
> > > oCmdInsert.CommandText = "SpDeneme";
> > > oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
> > > oAdp.InsertCommand = oCmdInsert;
> > > oAdp.Update(oTbl);
> > >
> > >
> > > But if I use this code then all is ok. I use here CommandType.Text
> > >
> > > SqlCommand oCmdInsert = new SqlCommand();
> > > oCmdInsert.Connection = Db.CNN;
> > > oCmdInsert.CommandType = CommandType.Text ;
> > > oCmdInsert.CommandText = "INSERT INTO TblDeneme (Alan1) VALUES
> (@Alan1)";
> > > oCmdInsert.Parameters.Add("@Alan1", SqlDbType.Int,4,"Alan1");
> > > oAdp.InsertCommand = oCmdInsert;
> > > oAdp.Update(oTbl);
> > >
> > >
> > >
> > >
> > > GD...
> > >
> > >
> > >
> > >
> > >
>
>