Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » ADO.Net   (RSS)

DataTable.GetChanges(DataRowState.Modified) returns NULL

The scenario; you have a DataGridView on a Windows Form, you then manually, in code, create a DataTable and set this to be the DataSource of the DataGrid. You then edit some of the data in the grid and then you need to get hold of a subset of data containing
Posted by maspeng | 0 Comments
Filed under:

"There is already an open DataReader associated with this Command which must be closed first" explained

Short one. This sometimes catches people out. When reading a SqlDataReader and then after the read is done, there is an attempt to use the connection that was used for the reading. The exception thrown is (in this case it is thrown when trying to update
Posted by maspeng | 0 Comments
Filed under: ,

IsolationLevel is carried over to connections in connectionpool

When using SqlConnection and Transactions you my get a somewhat unexpected behavior. Namely that when you pick a connection from the connection pool, the connection you get will have inherited the IsolationLevel from what was set on the connection when
Posted by maspeng | 0 Comments
Filed under:

SQL CLR stored procedure called via JDBC using setAutoCommit(false) does not update database.

I have come across this question a few times; “I have a java client that connects to SQL Server via the JDBC driver. I then call a CLR stored procedure that interacts with the database. When I run with setAutoCommit false the data is not committed. However,
Posted by maspeng | 0 Comments
Filed under: ,

System.Data.SqlClient.SqlException: Cannot open database "database name" requested by the login. The login failed.

A short one today, this is about one of the slightly confusing error messages when it comes to connecting to SQL Server, namely: System.Data.SqlClient.SqlException: Cannot open database "database name" requested by the login. The login failed. Login failed
Posted by maspeng | 0 Comments
Filed under: ,

How use Convert in a DataTable select?

How to use Convert() when doing DataTable.Select ? Sometimes you may need or want to select out a number of rows from a DataTable using the LIKE operator, this is no problem on a column with a string type. But what if you wish to do it on a column with,
Posted by maspeng | 1 Comments
Filed under: ,

A simple example on how to get Return and Out parameter values using Ado.Net

Another short one. How to capture OUT and RETURN parameter values from a stored procedure in .Net. Well, I’ll let the example speak for itself. First create a stored procedure, this just take an in parameter and an out parameter, it declares a local variable
Posted by maspeng | 1 Comments
Filed under: ,

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method. Why is that? Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are
Posted by maspeng | 0 Comments
Filed under:

(provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)

The scenario: You try to connect to Sql Server but you are getting the following connection error (they vary depending on the provider used): Using the .Net SqlClient provider: ------------------------------------------------------------------------------------------------------------------------------------------------------------
Posted by maspeng | 1 Comments

Unable to find the requested .Net Framework Data Provider. It may not be installed.

From .Net 2.0 there is an option for you to obtain your dataprovider (usually if using 3 rd party providers) by using the DbProviderFactories/ DbProviderFactory classes . A simple example: string provider = "System.Data.SqlClient" ; DbProviderFactory
Posted by maspeng | 1 Comments
Filed under:
 
Page view tracker