Under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction?

What does it mean for an SqlConnection to be “enlisted” in a transaction? Does it simply mean that commands I execute on the connection will participate in the transaction? If so, under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction? See questions in code comments. My guess to each question’s answer … Read more

Get the generated SQL statement from a SqlCommand object?

I have the following code: Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = “UPDATE someTable SET Value = @Value” cmd.CommandText &= ” WHERE Id = @Id” cmd.Parameters.AddWithValue(“@Id”, 1234) cmd.Parameters.AddWithValue(“@Value”, “myValue”) cmd.ExecuteNonQuery End Using I wonder if there is any way to get the final SQL statment as a String, which should look like this: UPDATE … Read more

Using MySQL with Entity Framework [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 years ago. Improve this question Can’t find anything relevant about Entity Framework/MySQL on Google so I’m hoping someone knows about it. 10 Answers 10

How to use DbContext.Database.SqlQuery(sql, params) with stored procedure? EF Code First CTP5

I have a stored procedure that has three parameters and I’ve been trying to use the following to return the results: context.Database.SqlQuery<myEntityType>(“mySpName”, param1, param2, param3); At first I tried using SqlParameter objects as the params but this didn’t work and threw a SqlException with the following message: Procedure or function ‘mySpName’ expects parameter ‘@param1’, which … Read more

Entity Framework and Connection Pooling

I’ve recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling. Connection pooling as I know is managed by the ADO.NET data provider, in my case that of MS SQL server. Does this apply when you instantiate a new entities context (ObjectContext), … Read more

Get connection string from App.config

var connection = ConnectionFactory.GetConnection( ConfigurationManager.ConnectionStrings[“Test”] .ConnectionString, DataBaseProvider); And this is my App.config: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <connectionStrings> <add name=”Test” connectionString=”Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True” providerName=”System.Data.SqlClient” /> </connectionStrings> </configuration> But when my project runs this is my error: Object reference not set to an instance of an object. 22 Answers 22