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).

10075 questions
187
votes
13 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,646
  • 4
  • 23
  • 31
173
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,739
  • 2
  • 11
  • 4
170
votes
8 answers

Call a stored procedure with parameter in c#

I'm able to delete, insert and update in my program and I try to do an insert by calling a created stored procedure from my database. This button insert I made works well. private void btnAdd_Click(object sender, EventArgs e) { SqlConnection…
FrankSharp
  • 2,552
  • 10
  • 38
  • 49
148
votes
10 answers

Entity Framework with NOLOCK

How can I use the NOLOCK function on Entity Framework? Is XML the only way to do this?
OneSmartGuy
  • 2,849
  • 4
  • 25
  • 24
137
votes
2 answers

ExecuteReader requires an open and available Connection. The connection's current state is Connecting

When attempting to connect to MSSQL database via ASP.NET online, I will get the following when two or more people connect simultaneously: ExecuteReader requires an open and available Connection. The connection's current state is Connecting. The…
Guo Hong Lim
  • 1,690
  • 3
  • 13
  • 20
136
votes
7 answers

How to change the DataTable Column Name?

I have one DataTable which has four columns such as StudentID CourseID SubjectCode Marks ------------ ---------- ------------- -------- 1 100 MT400 …
thevan
  • 10,052
  • 53
  • 137
  • 202
136
votes
10 answers

What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery?

What are the different cases when we use these three? Where should I use one and where should I not?
nectar
  • 9,525
  • 36
  • 78
  • 100
133
votes
3 answers

DbArithmeticExpression arguments must have a numeric common type

TimeSpan time24 = new TimeSpan(24, 0, 0); TimeSpan time18 = new TimeSpan(18, 0, 0); // first get today's sleeping hours List sleeps = context.Sleeps.Where( o => (clientDateTime - o.ClientDateTimeStamp < time24) && …
Nawaz Dhandala
  • 2,046
  • 2
  • 17
  • 23
131
votes
24 answers

Connection to SQL Server Works Sometimes

An ADO.Net application is only sometimes able to connect to another server on the local network. It seems random whether a given connection attempt succeeds or fails. The connection is using a connection string in the…
Eric J.
  • 147,927
  • 63
  • 340
  • 553
129
votes
5 answers

Populate data table from data reader

I'm doing a basic thing in C# (MS VS2008) and have a question more about proper design than specific code. I am creating a datatable and then trying to load the datatable from a datareader (which is based on an SQL stored procedure). What I'm…
Ryan Ward
  • 1,523
  • 4
  • 15
  • 23
127
votes
9 answers

Check if SQL Connection is Open or Closed

How do you check if it is open or closed I was using if (SQLOperator.SQLCONNECTION.State.Equals("Open")) however, even the State is 'Open' it fails on this check.
user222427
119
votes
3 answers

Connection timeout for SQL server

Can I increase the timeout by modifying the connection string in the web.config?
Xander
  • 9,069
  • 14
  • 70
  • 129
111
votes
14 answers

How can I query for null values in entity framework?

I want to execute a query like this var result = from entry in table where entry.something == null select entry; and get an IS NULL generated. Edited: After the first two answers i feel the need to…
Adrian Zanescu
  • 7,907
  • 6
  • 35
  • 53
110
votes
2 answers

ADO.NET DataRow - check for column existence

How do I check for the existence of a column in a datarow? I'm building datatables to organize some data that I've already pulled back from the database. Depending on the type of data in each row, I need to create a datatable with different…
Tone
  • 2,793
  • 6
  • 29
  • 42
110
votes
6 answers

Invalid attempt to read when no data is present

private void button1_Click(object sender, EventArgs e) { string name; name = textBox5.Text; SqlConnection con10 = new SqlConnection("con strn"); SqlCommand cmd10 = new SqlCommand("select * from sumant where…
knowledgehunter
  • 1,345
  • 4
  • 11
  • 10