ado.net

How to connect to database after failover?

I set up a database mirroring and then used this connectionstring to connect to it: Data Source={0};Failover Partner={1};Initial Catalog=AdventureWorks; Integrated Security=True; After adding some data into database, I shutdown the principal server, so the mirror server becomes the principal server. I open the connection again...

How to tell if user has modified data using bindingsource

I have a DataGridView bound to a bindingsource which is bound to a List<T>. The user clicks a row that goes to a form with textboxes etc. The textboxes are databound like so: if (txtID.DataBindings.Count == 0) txtID.DataBindings.Add("Text", bindingSource, "Title"); I want to be able to detect if the user has modified...

How do I safely use ADO.NET IDbConnection and IDbCommand to execute multiple database commands concurrently?

The Goal Use an ADO.NET IDbConnection and IDbCommand to execute multiple commands at the same time, against the same database, given that the ADO.NET implementation is specified at runtime. Investigation The MSDN Documentation for IDbConnection does not specify any threading limitations. The SqlConnection page has the standard disclai...

Connection string in ADO. Net

what code should i write in web.config for the connection string for DB connectivity woth ado.net component?? ...

How can use Ado. Net from Delphi Win32

Is possible to use ADO .Net from an Win32 Application build with Delphi 7. maybe using CrossTalk or Hydra? Any recommendation is welcome. thanks in advance. ...

Datalist - No databind to server control, extract possible?

In a datalist, you usually extract row data with a FindControl on a control that is assigned a value via a databind using say, Eval. What if in your datalist, there is no bind to an ASP.NET server control? It's in a datalist, "straight up", in say a table cell or on its own. You can't do a FindControl, so is it possible to extract a r...

TransactionScope helper that exhausts connection pool without fail - help?

A while back I asked a question about TransactionScope escalating to MSDTC when I wasn't expecting it to. (Previous question) What it boiled down to was, in SQL2005, in order to use a TransactionScope, you can only instance and open a single SqlConnection within the life of the TransactionScope. With SQL2008, you can instance multiple ...

.net 2.0: What's the best way to deal with in-memory DataTables?

Hi, I have a csv file that I import into a DataTable. Furthermore I've created a TableAdapter with several queries. Is it somehow possible to execute the queries associated with the TableAdapter directly on the "in-memory" DataTable (doesn't seem so) or do I always have to write the imported DataTable to the database first and then exec...

What happens if I leave a database connection open in an ASP.NET web page

Suppose that I have an ASP.NET page. In the page load event handler, I open a database connection and do some processing. But after the processing is done, I don't close the connection explicitly by calling the CLOSE method of the connection object. Now when the page processing at the server side is finished, the GC will dispose all the...

How to avoid IndexOutOfRangeException indexing DataReader columns?

I am having a little trouble with an 'IndexOutOfRangeException'. I think it is because when the code tries to get the DateModified col from the database it sometimes contains NULLS (the users haven't always updated the page since they created it). Here is my code; s = ("select datemodified, maintainedby, email, hitcount from updates wh...

ADO.NET: What API I can use to get message when SET NOCOUNT OFF

Hi guys: Many articles recommend adopting "SET NOCOUNT ON" to avoid receiving message like "1 Row(s) affected". I'm curious what ADO.NET API I can use to get message when SET NOCOUNT OFF. Thanks. ...

Repository implementation using ADO.NET SqlConnectin DataReader ... all that stuff

Possible Duplicate: Repository pattern tutorial in C# anybody knows where can I find an example of Repository Implementation using just ADO.NET without any 3rd party components like Nhibernate ...

ADO.NET and SQL Server stored procedures - SELECT after INSERT, UPDATE, DELETE

In a large project relying on SQL Server stored procedures and classic ADO.NET (DataSets, DataAdapters) after INSERT, DELETE and UPDATE procedures there is a SELECT following. In code, all the methods return void, is this SELECT of any relevance - what effect does in have? What is the performance impact of the SELECT? ...

is it ok to do the Data Access Layer using only SqlConnection SqlCommand and SqlDataReader

I know that nowadays there is a lot of ready-to-go stuff that you can use, but if you want full control over db requests/queries, and best performance I think that this is the way to go. Also because ADO.NET does the connection pooling automatically for SqlConnection, how do you think ? ...

Entity Framework and Link Table issue

Hi, I have a database which consists of the following: ** Table 1 ** Id (PK) Field1 ** Table 2 ** Id (PK) Field2 ** Link Table ** Table1Id (FK) Table2Id (FK) The problem is, I cannot access Table 2 from Table 1, even though the relationship exists in the database. For example, the following should be possible: var Results...

Microsoft.Jet.OLEDB.4.0 provider turns string into a date

I am using Microsoft.Jet.OLEDB.4.0 from .NET to read a CSV file. Here is a sample input data row: 102A Avenue,97 Street,99 Street,2 Lanes Closed,2007-04-13,2009-12-31 When I read the last two valuee they come out as DateTime rather than strings and that is neither what I want nor what I expect. It seems that the provider performs type...

Set Default Datbase for an OBDC DSN Connection .Net

Is there any way to set the default database of an ODBC DSN, using the ODBC connection string in an OdbcConnection? Edit: If I already have a DSN setup and a normal connection works. OdbcConnection connection = new OdbcConnection("DSN=TestDSN;UID=ADMIN;PWD=****;"); Is there a way I can change the default connection that is set ...

do we need using for the SqlCommand or is it enough just for the SqlConnection and SqlDataReader

i took this code from msdn string connString = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"; using (SqlConnection conn = new SqlConnection(connString)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT CustomerId, CompanyName FROM Customers"; conn.Open(); ...

Datatype mismatch issue in a Parametrized insert query

I have this code to transfer records from one-table to the other cmd2.CommandText = "select * from " + TableName; reader = cmd2.ExecuteReader(); if (reader != null) { String s = "".PadLeft(reader.FieldCount - 1, 'X').Replace("X", "?,") + "?"; ...

Remove duplicates by field from one table using another using LINQ

I have to leave in a DataTable only records with dates currently not present in the database. So I read all existing dates using the stored procedure (is it correct?): SELECT DISTINCT CAST(S.[date] AS DATE) -- original date is DATETIME2(0) FROM ... WHERE ... and load it to a DataTable: var tableDate = new DataTable(); new SqlDataAda...