Questions tagged [ado.net]

ADO.Net is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. It is a part of the base class library that is included with the Microsoft .NET Framework.

ADO.NET is a set of computer software components that programmers can use to access data and data services. It is a part of the base class library that is included with the Microsoft .NET Framework.

It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but it was changed so extensively that it can be considered an entirely new product.

In modern practice, ADO.NET is often implemented along side the query language LINQ, and the Entity Framework (Microsoft's OR/M persistence layer).

9697 questions
705
votes
43 answers

MetadataException: Unable to load the specified metadata resource

All of a sudden I keep getting a MetadataException on instantiating my generated ObjectContext class. The connection string in App.Config looks correct - hasn't changed since last it worked - and I've tried regenerating a new model (edmx-file) from…
J. Steen
  • 14,900
  • 15
  • 57
  • 62
688
votes
22 answers

How do I view the SQL generated by the Entity Framework?

How do I view the SQL generated by entity framework ? (In my particular case I'm using the mysql provider - if it matters)
nos
  • 207,058
  • 53
  • 381
  • 474
434
votes
5 answers

Entity Framework VS LINQ to SQL VS ADO.NET with stored procedures?

How would you rate each of them in terms of: Performance Speed of development Neat, intuitive, maintainable code Flexibility Overall I like my SQL and so have always been a die-hard fan of ADO.NET and stored procedures but I recently had a play…
BritishDeveloper
  • 12,481
  • 7
  • 49
  • 59
404
votes
21 answers

Get connection string from App.config

var connection = ConnectionFactory.GetConnection( ConfigurationManager.ConnectionStrings["Test"] .ConnectionString, DataBaseProvider); And this is my App.config:
349
votes
17 answers

SET NOCOUNT ON usage

Inspired by this question where there are differing views on SET NOCOUNT... Should we use SET NOCOUNT ON for SQL Server? If not, why not? What it does Edit 6, on 22 Jul 2011 It suppresses the "xx rows affected" message after any DML. This is a…
gbn
  • 394,550
  • 75
  • 549
  • 647
293
votes
10 answers

Can you get the column names from a SqlDataReader?

After connecting to the database, can I get the name of all the columns that were returned in my SqlDataReader?
Blankman
  • 236,778
  • 296
  • 715
  • 1,125
271
votes
4 answers

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…
Noldorin
  • 134,265
  • 53
  • 250
  • 293
268
votes
10 answers

Using MySQL with Entity Framework

Can't find anything relevant about Entity Framework/MySQL on Google so I'm hoping someone knows about it.
vintana
  • 2,893
  • 2
  • 16
  • 12
260
votes
10 answers

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("mySpName", param1, param2, param3); At first I tried using SqlParameter objects as the…
electricsheep
  • 4,834
  • 8
  • 35
  • 41
218
votes
13 answers

How to create a DataTable in C# and how to add rows?

How do create a DataTable in C#? I did like this: DataTable dt = new DataTable(); dt.clear(); dt.Columns.Add("Name"); dt.Columns.Add("Marks"); How do I see the structure of DataTable? Now I want to add ravi for Name and 500 for Marks. How can I…
Cute
  • 12,313
  • 34
  • 91
  • 111
203
votes
3 answers

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…
Triynko
  • 17,370
  • 20
  • 92
  • 154
201
votes
5 answers

What size do you use for varchar(MAX) in your parameter declaration?

I normally set my column size when creating a parameter in ADO.NET But what size do I use if the column is VARCHAR(MAX)? cmd.Parameters.Add("@blah", SqlDbType.VarChar, ?????).Value = blah;
mrblah
  • 88,033
  • 134
  • 292
  • 404
201
votes
24 answers

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) …
dummy
  • 3,956
  • 3
  • 22
  • 35
176
votes
12 answers

entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1

I am trying to save Employee details, which has references with City. But everytime I try to save my contact, which is validated I get the exception "ADO.Net Entity Framework An entity object cannot be referenced by multiple instances of…
Smily
  • 2,486
  • 4
  • 19
  • 31
169
votes
8 answers

Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime

I'm getting the following exception: Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. as I was trying to export crystal report from my…
Christina Wong
  • 1,699
  • 2
  • 11
  • 4
1
2 3
99 100