G
Gurkan
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...
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...