tagged [ado.net]

Is There Any Difference Between SqlConnection.CreateCommand and new SqlCommand?

Is There Any Difference Between SqlConnection.CreateCommand and new SqlCommand? In .Net, is there any functional difference between creating a new `SqlCommand` object and attaching a `SqlConnection` t...

23 Apr at 15:39

What is the use/advantage of using CommandBehavior.CloseConnection in ExecuteReader()

What is the use/advantage of using CommandBehavior.CloseConnection in ExecuteReader() Can anyone tell me what is the `CommandBehavior.CloseConnection` and what is the use/benefit of passing this as a ...

24 Oct at 14:7

What is the difference between dataview and datatable?

What is the difference between dataview and datatable? What is the difference between DataView and DataTable in .NET? As far as I understand, DataView is just a false presentation of DataTable. When s...

27 Dec at 14:29

ADO.NET: convert a DataTable to an array of DataRows

ADO.NET: convert a DataTable to an array of DataRows I'm using ADO.NET and C#, and I want to convert a DataTable object into an array of DataRows. What is an elegant way of doing this?

21 Jul at 05:42

Check if SQL Connection is Open or Closed

Check if SQL Connection is Open or Closed How do you check if it is open or closed I was using however, even the State is 'Open' it fails on this check.

27 Mar at 19:47

When using Trusted_Connection=true and SQL Server authentication, will this affect performance?

When using Trusted_Connection=true and SQL Server authentication, will this affect performance? If a connection string specifies `Trusted_Connection=true` with SQL Server authentication mode, will per...

How to resolve System.Type to System.Data.DbType?

How to resolve System.Type to System.Data.DbType? What is the best way to find [System.Data.DbType](http://msdn.microsoft.com/en-us/library/system.data.dbtype.aspx) enumeration value for Base Class Li...

31 Oct at 09:57

How to delete multiple rows in a DataTable?

How to delete multiple rows in a DataTable? How can I delete specific DataRows within a loop of a DataTable rows which meet a custom condition -lets say the rows having an index of even number-? (With...

26 May at 13:8

Encrypt password in App.config

Encrypt password in App.config I want to encrypt the password in connection string. When I make a connection to DB the connection string is openly stored in App.config and I need to find a way to keep...

2 Apr at 11:31

C# SQLConnection pooling

C# SQLConnection pooling Can anyone brief me how to do Connection Pooling in ADO.Net, I do need to connect to 3 separate databases. 2 of them are in same server and the other in a separate one. Better...

28 Jul at 08:21

Get Columns of a Table by GetSchema() method

Get Columns of a Table by GetSchema() method I want to get list of columns of a table using `GetSchema` method in `ADO.Net`, my code is: And i get an empty `DataTable`, what is the problem?

22 Jun at 16:50

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

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 of type `VARCHAR(MAX)`?

22 Jun at 09:33

.net connection pooling

.net connection pooling I don't get what is the syntax difference between regular connection and connection pool. When I'm using the `using` key such as: Is this the way to perform a connection pool?

29 Jul at 21:47

Creating a SQL Server table from a C# datatable

Creating a SQL Server table from a C# datatable I have a DataTable that I manually created and loaded with data using C#. What would be the most efficient way to create a table in SQL Server 2005 that...

28 Aug at 18:46

In-Out Parameter for SqlCommand

In-Out Parameter for SqlCommand I have the following parameter for SqlCommand. How do I make it to both in and out the paramter value for the Stored Procedure.

16 Jul at 23:15

Rhino Mocks: How to mock ADO.NET's DataRow?

Rhino Mocks: How to mock ADO.NET's DataRow? ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. Does...

1 Oct at 01:2

Get output parameter value in ADO.NET

Get output parameter value in ADO.NET My stored procedure has an output parameter: How can I retrieve this using ado.net? ``` using (SqlConnection conn = new SqlConnection(...)) { SqlCommand cmd = n...

8 May at 18:22

How to test if a DataSet is empty?

How to test if a DataSet is empty? I'm modifying someone else's code where a query is performed using the following: How can I tell if the DataSet is empty (i.e. no results were returned)?

4 Jun at 17:41

What does Trusted = yes/no mean in Sql connection string?

What does Trusted = yes/no mean in Sql connection string? What does Trusted = yes/no mean in Sql connection string? I am creating a connection string as below : Please Help

7 Aug at 05:11

Insert 2 million rows into SQL Server quickly

Insert 2 million rows into SQL Server quickly I have to insert about 2 million rows from a text file. And with inserting I have to create some master tables. What is the best and fast way to insert su...

Specific cast is not valid, while retrieving scope_identity

Specific cast is not valid, while retrieving scope_identity I am getting exception: "Specific cast is not valid", here is the code

12 Jun at 06:34

MultipleActiveResultSets=True or multiple connections?

MultipleActiveResultSets=True or multiple connections? I have some C# in which I create a reader on a connection (`ExecuteReader`), then for every row in that reader, perform another command (with `Ex...

How Do I Get the Selected DataRow in a DataGridView?

How Do I Get the Selected DataRow in a DataGridView? I have a DataTable bound to a DataGridView. I have FullRowSelect enabled in the DGV. Is there a way to get the selected row as a DataRow so that I ...

C# - What are Some High Performance Best Practices/Tips for ADO.NET

C# - What are Some High Performance Best Practices/Tips for ADO.NET I decided not to use an orm and going to use straight ADO.NET for my project. I know I know its gonna take longer to program but I j...

9 Jun at 14:5

Are there any benefits of reading each field async from a SqlDataReader?

Are there any benefits of reading each field async from a SqlDataReader? Is there any gain in reading the fields asynchronously? Say if I have the following: ``` SqlDataReader reader = await cmd.Execu...

10 Nov at 20:46