ado.net

ADO.NET Sync Framework - Determining which records synced successfully/failed from PDA to Server.

I am using ADO.NET Sync Framework and on the client side (PDA running Windows Mobile 5 and .net cf 3.5 and SQL CE 3.5). Server side is using SQL Server 2005. On server side manual queries have been written to determine which records are selected for insert/update/delete for each client as well as any conflicting records. On PDA though...

Repository pattern, sharing connections

I've found lots of examples of the repository pattern, all of which show the repository managing it's own connection lifecycle. I was wondering how people deal with a case where they want to share a single connection across multiple repositories? The main reason I'm asking is because when I create a transaction, using TransactionScope,...

what characters should be escaped in sql string parameters

I need a complete list of characters that should be escaped in sql string parameters to prevent exceptions. I assume that I need to replace all the offending characters with the escaped version before I pass it to my ObjectDataSource filter parameter. ...

C# - IDataReader to Object mapping using generics.

How can I map a DataReder object into a class object by using generics? For example I need to do the following: public class Mapper<T> { public static List<T> MapObject(IDataReader dr) { List<T> objects = new List<T>(); while (dr.Read()) { //Mapping goes here... ...

Retrieving a DateTime value from a DataRow (C#)

How can I get DateTime value in C# from row, the current code is giving me error any help is appreciated, the data is coming in from progress database: foreach (DataRow r in ds.Tables[0].Rows) { string prodCode = r["PRD-CDE"].ToString(); statCode = r["STAT"].ToString(); DateTime firstIssueDate = (DateTime)(r["FISS"]); D...

C# - A class for Generic database connection, command, reader.

Suppose I am designing a class that can handle any database technology to create a connection, execute command and retrieve data, etc. If I need to create a generic database handling class for existing RDBMSs (like SQL Server, Oracle, FireBird, et.), which .net abstract-class/Interface should I use {DbConnection, DbCommand, DbParameter,...

How can we solve concurrency in asp.net

In asp.net web site, We have enry form which can be accessible to administrator. There are more then one administrator for entry. If all admin open form simultaneous and select some combobox value from form then how can we maintained concurrency Because once first admin select value from combox and save then that value should remove fr...

Do ADO.Net DataTables have indexes?

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 + SQL Server 2008 + ADO.Net. If I load a table from a database by using a DataTable of ADO.Net, and in the database table, I defined a couple of indexes on the table. My question is, whether on the ADO.Net DataTable, there is related index (the same as the indexes I created on physica...

ADO.NET Entity Connection String for Multiple Projects

I am using multiple layer project where the DataModel hosts the ADo.NET Entity model and DataAccess layer does the validation. However everytime I get a error like this The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. I have tried connec...

Best practice creating LINQ-to-SQL classes to deal with the same entity present in 10 different data sources?

I was wondering what would be the best way to create LINQ-to-SQL classes to deal with a given entity which is present in 10 different data sources. Let's say I've got the same database in 10 different countries, each of them with a Customers table, and my goal is to access all of them programatically. Should I either create: a single A...

SQL Server 2008 import schema and data from ADO.NET Provider?

I am trying to figure how to get SQL Server 2008 to import data using the schema from an ADO.NET Provider. You can use the Database Import wizard and choose any ADO.NET Provider (I am using VistaDB in this case). But once you go to the actual import the Copy Data from one or more tables is grayed out. You can only write queries. I wa...

What problem is Microsoft trying to solve with all of these data access strategies?

There seems to be many different data access strategies coming out of Microsoft. There’s ‘classic’ ADO.NET, Linq2Sql, ADO.NET Entity Framework, ADO.NET Data Services, ADO.NET Dynamic Data. I’m sure that I’ve missed some. To me, it seems that there’s a lot of confusion surrounding where each frameworks fit into an application's architectu...

Reducing roundtrips to the server/database

When writing ASP.NET pages, what signs do you look for that your page is making too many roundtrips to a database or server? (This is a general question but I say ASP.NET as the majority of my coding is on the web side of things). ...

Add a DbProviderFactory without an App.Config

I am using DbProviderFactories in my data layer (based on Entity Framework) and am using SQLite for my database, but I don't have to have a App.Config to have the following code: <configuration> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite"/> <add name="SQLite Data Provider" invariant="Syst...

.NET READPAST lock error when calling a stored procedure.

I'm trying to call a stored procedure from my .NET code which has one output paramater. Its all standard ADO.NET stuff using SqlCommand, SqlParameter and so on. But I'm getting the error below even though my transaction level is READ COMMITTED. You can only specify the READPAST lock in the READ COMMITTED or REPEATABLE READ isolation le...

C# + LINQ + ADO.NET EF , join 2 tables and return everything without specifying all fields manually

I have a simple LINQ query on ADO.NET Entity Framework as follows var result = from itemA in TableA join itemB in TableB on itemA.ID = itemB.ID select ?????? I am trying to select everything from itemA and itemB without specifying all the TableA and TableB. anything thoughts??? ...

ASP.NET Provider Model for Data Access

Hello Just been introduced to the ASP.NET Provider Model as a potential data-access technology. My own idea is to use LINQ repositories, but want to keep an open mind. Any thoughts? Thanks ...

Easy way to write a string with control characters to an nvarchar field in a DB?

EDIT: Accepted answer points out what my issue was. I added another answer which shows an even easier way. I have a multiline textbox from which I create a single string: Dim wholeThing As String Dim line as String For Each line In txtMultiline.Lines wholeThing = wholeThing & line & Environment.Newline Next ...

Should I use static methods for DataAccess common operators?

I'm not using hibernate and that's not a valid alternative at all. I developed a framework based on ADO.NET. This framework has default operators for each database entity. For example, data access layers has default operators as the following: Insert Update Delete Get GetAll To access this methods, we work as tha sample code below: ...

When should I consider using an ORM framework?

I am developing an application which at the moment queries a (rather large) database via ADO.NET and hard-coded SQL statements. Admittedly this is ugly (i.e. no compile time errors thrown if a mistake is made in the SQL) and potentially dangerous (due to SQL injections, etc although this is unlikely to be a problem for this particular ap...