views:

59

answers:

3

i try to use erpCtx.Executecommand but i doesn't have method of executecommand. i think that i must add dll in Reference to show executeCommand?

alt text

i need : int rowsAffected = engCtx.ExecuteCommand("insert into ENG_MAINWP Values({0},{1},{2},{3})", engArray[0], engArray1, engArray[2], engArray[3]);

A: 

Something like this?

 using (var db = new DAL.CrawlerDalEntities())
        {
            db.Connection.Open();
            using (var cmd = db.Connection.CreateCommand())
            {
                cmd.CommandTimeout = storedProcedureDefaultTimeout;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "CrawlerDalEntities.PerformBackup";

                cmd.Parameters.Add(new EntityParameter
                {
                    ParameterName = "fileName",
                    Value = fileName,
                    DbType = DbType.String
                });

                cmd.Parameters.Add(new EntityParameter
                {
                    ParameterName = "backupName",
                    Value = backupName,
                    DbType = DbType.String
                });

                cmd.ExecuteNonQuery();
            }
            db.Connection.Close();
        }
lak-b
Thanks But i need: int rowsAffected = engCtx.ExecuteCommand("insert into ENG_MAINWP Values({0},{1},{2},{3})", engArray[0], engArray[1], engArray[2], engArray[3]);
Phsika
ist it Clear? i updated my Question...
Phsika
A: 

In the Entity Framework, it's called ExecuteStoreCommand.

Stephen Cleary
A: 

DataContext.ExecuteCommand is in:

Namespace: System.Data.Linq
Assembly: System.Data.Linq (in System.Data.Linq.dll)

Source

ChrisF
i add it but result the same as before. LOOK please: http://i34.tinypic.com/1z1wq51.jpg
Phsika
@Phsika - in that case I don't know. Do a clean and rebuild?
ChrisF