ado.net

Which Data Acccess layer is the recommended today for ASP.net?

Good day! I'm currently building a small website where I write down problems that arise and answers to them for others to see. Currently I'm using a DAL much like the one described here. Now I have been looking at other models, and in particular linq based models using Linq2SQL and the ADO.net Entries framework. I realize I'm moving the...

ADO.Net Entity Framework An entity object cannot be referenced by multiple instances of IEntityChangeTracker

Hi, I am trying to save my contact, which has references to ContactRelation (just the relationship of the contact, married, single, etc) and Country. 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 IEntityChangeTracker...

Best way to set strongly typed dataset connection string at runtime?

My Windows Forms application uses a strongly typed dataset created using the designer in Visual Studio. At runtime I would like to be able to select either the live or test database. What is the best way to programmatically set the connection string for the dataset at runtime? ...

Obscure Relational Database Mapping to C# Dataset

Hi, apologies for the previous post, sometime writing the questions actually solves it too ;) as in "the answer is in the question" So I'm trying to interface an old primitive database system that is accessed vi a DLL entry point, however some work has been done on object rational mapping where one can create objects of each table and a...

Sync Services Ado.net conflict resolution

is it possible to solve conflicts on client side with sync services for ado.net? for example, with Client Insert Server Insert, updating client's table id (on client side) , tks ...

Sync Services Ado.net define Range Id

is there a way to define a range of id's for insertions in a table in a client DB, using Sync Services for ado.net? does Sync services have any predicted support for such a case? tks ...

Steps for PostBack

I come to you this time with a question to do with .NET. I was given the challenge of finding out the four steps involved with postback. The exact challenge is: "There are four methods executed each time there is a postback. Describe and identify each." From what I can tell (this is a challenge for a .NET class), postback is what oc...

insert records in database from an xml

Am writing a .net windows service using which i need to parse an xml (having about 5000 nodes). I need to parse these nodes and insert data (ie. 5000 rows)into a sql database. Shall I insert all these records with batch insert or shall i insert them one by one? can someone help me with the design/algorithm for optimum performance? ...

Adding a record to an access database, Where is the error in this code?

read a lot about DataAdapter, DataTable ,.. to reach to this code, in the Save Button: 'insert new row ds.Tables("Employees").Rows.Add(ENumTxt.Text, ENameTxt.Text, EPosTxt.Text, EAgeTxt.Text, ESalTxt.Text, EPhonTxt.Text, EAdrsTxt.Text) 'save changes ds.AcceptChanges() Try If ds.HasChanges Then Dim AffectedDS As DataSet = ds.Ge...

SQL: Update a row and returning a column value with 1 query

I need to update a row in a table, and get a column value from it. I can do this with UPDATE Items SET Clicks = Clicks + 1 WHERE Id = @Id; SELECT Name FROM Items WHERE Id = @Id This generates 2 plans/accesses to the table. Is possibile in T-SQL to modify the UPDATE statement in order to update and return the Name column with 1 plan/ac...

How do I "SET ROWCOUNT 1000" in ADO.NET?

I need to make sure my ado.net commands don't return more than 1000-5000 rows. Is there an ADO.NET way to do this, or is it just a TSQL? I'm calling a stored procedure, I don't control the source code in that stored procedure. Hence I was hoping there was a ADO.NET way to do it. ...

What is the best way to save XML data to SQL Server?

Is there a direct route that is pretty straight forward? (i.e. can SQL Server read XML) Or, is it best to parse the XML and just transfer it in the usual way via ADO.Net either as individual rows or perhaps a batch update? I realize there may be solutions that involve large complex stored procs--while I'm not entirely opposed to this,...

How-to Prevent Dirty Records to be updated

Assuming a Product class public class Product { public String Name {get;set;} public Decimal Price {get;set;} public Int32 QuantityStock {get;set;} } Now assuming Two Clients who "Request" the same Product at the same time named "Product 1" with the following values Name = "Product 1" Price = 10 QuantityStock = 100 The...

How to generate table from model in ADO.NET Entity Framework?

How is it possible to create an entity in the visual studio designer and generate a table from it? I find it much easier to generate my entities within VS than to create a table in SQL Server. Also, if I do generate an entity from table, is it possible to make changes to the entity and push them to the table? ...

Base64 String throwing invalid character error.

I keep getting a Base64 invalid character error even though I shouldn't. The program takes an XML file and exports it to a document. If the user wants, it will compress the file as well. The compression works fine and returns a Base64 String which is encoded into UTF-8 and written to a file. When its time to reload the document into th...

What is the best way to handle (nested) record sets?

Hi to all. What are the best (cleaner, less resource expensive) ways to pass one-to-many relationships from a db server to a client? Imagine that I have a Author table and a Book table. I want to to retrieve all the authors whose name starts with "a" and all the books they've written. Then, client-side, generate an array of objects "Aut...

ADO.NET SQL Client Provider default database connection

Does the .NET SQL Client DataProvider always connect using the master database. I've noticed that when I connect to the database to execute an ADO.NET query and then look at the active connections in SQL Management studio, the SPID for the .NET SQL client provider always uses master DB The initial catalog in my connection string is tha...

How to work with dataset's datarelation in linq?

Can someone provide an example of linq querying various nested tables in a dataset? I can't find something like that on the net. Thanks ...

How to best insert 350,000 rows with ADO.Net

I have a csv file with 350,000 rows, each row has about 150 columns. What would be the best way to insert these rows into SQL Server using ADO.Net? The way I've usually done it is to create the SQL statement manually. I was wondering if there is any way I can code it to simply insert the entire datatable into SQL Server? Or some shor...

Entity Framework: Should the EntityContainer name contain at least two words?

I am using entity framework, using (almost) hand-crafted csdl, ssdl, and msl files. I've noticed that object construction seems to fail if the name of the EntityContainer consists of a single word. For example, for the following two csdl files : <Schema Namespace="BestProduct" Alias="Self" xmlns="http://schemas.microsoft.com/ad...