ado.net

ado.net data services - how to grab subsets of data from the data model?

Hi, Im starting to use ado.net data services in a little silverlight application that Im putting together. Currently I'm using it in the most simplistic was possible: var teams = (from t in ents.tblTeams select t) as DataServiceQuery<tblTeams>; teams.BeginExecute( (ar) => this.cmTeams...

Using static data access methods with the ADO.NET Entity Framework

Hi I am using the ADO.NET entity framework for the first time and the staticcode analysis is suggesting I change the following method to a static one as below. My question is simple, is this thread safe? public static void InsertUserDetails(UserAccount userAccount) { using (KnowledgeShareEntities entities = new Kno...

How to tell if a SqlConnection has an attached SqlDataReader?

This is something now more of curiosity than actual purpose. If you have a SqlConnection opened and attach a SqlDataReader to it, and then try to run another query using the same SqlConnection then it will throw an error. My question is how does the SqlConnection know that a reader is attached to it. There is not a public property or any...

SET NOCOUNT ON and reading messages using C# and ADO.NET

Hi SET NOCOUNT ON stops the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set. a) How can you read these messages using C# and ADO.NET ( I assume C# code reading these messages is the same regardless of whether T-SQL ...

SqlConnection problem

My sqlconnection is SqlConnection(@"Data Source = John\Administrator; Initial Catalog = TicketingSystem; Integrated Security = true;"); I try to connect to the server but i cant this error pops up A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not ac...

How to copy data from an Oracle table into an SQLite Table using ado.net and few lines of code.

Hello: I need to do a generic C# program to let the data reading from an Oracle database table (T1) with, for example, field names a, b, c, d, and saving into an SQLite3 table (T2) with the same field names and types than T1, althought with additional fields that can have null values. I am using the different ado.net libraries provided...

ADO.NET Entity Data Model are not precise enough

I run this code: var cos = from k in _db.klienci_do_trasy where k.klient_id == 5 select k; but the query send to database is: SELECT * FROM `klienci_do_trasy` LIMIT 0, 30 why is it for, there is no condition on klient_id? ...

How do I update a single table of a DataSet using a TableAdapter, without hard-coding the table name?

This seems like a really basic thing that I'm doing, yet I'm tearing my hair out trying to make it work. My situation is this: I have a project which contains a large number of lookup tables, and I have all of these lookup tables represented in a single typed DataSet, which contains TableAdapters for each lookup. I've designed an edito...

ADO.NET entity data model deleting many rows

I have following structure of the database CREATE TABLE IF NOT EXISTS `klienci` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nazwa` varchar(50) NOT NULL, `miejscowosc` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `klienci_do_trasy` ( `klient_id` int(...

ADO.NET Entity Data Model - order of executing query

When I run this code: korlenEntities2 _db = new korlenEntities2(); for (int i = 0; i < 10; i++) { klienci klient = new klienci(); klient.nazwa = "Janek_" + i.ToString(); klient.miejscowosc = "-"; _db.AddToklienci(klient); }; _db.SaveChanges(); rec...

How do we solve all this "Conversion from type DBNull to type String is not valid" nastiness?

In our applications, I can't think of many cases where we care about null string fields. We just want them to show as empty strings in most situations. So when using the built in ADO.NET dataset / datatables, the error: Conversion from type DBNull to type String is not valid is all too common later on in the app when referring...

Is change-tracking in ORMs a necessity or a luxury, in the context of web apps?

Since web applications are mostly stateless, and linear (request comes in, response goes out), is change-tracking really necessary? E.g. if I have an action that updates a Product instance I know at code-time what state I'm changing, I can just tell the repository "please update this instance". To clarify, my question is about the chan...

How to get a set of rows from an array of id's ?

In C#, I have an array of integers, that represent the primary keys of rows in a Table in SQL Server. I need to select all these rows from SQL Server by executing a single Select command - preferably through a stored procedure. There may be from a few to hundreds of ID's in the array, and the solution needs to work on SQL Server 2005 an...

DataRelation: why ParentCol and ChildCol must have the same name ?

In the physical MS Access DB the name of child column is Customer but if I use childCol = dataSet.Tables["Orders"].Columns["Customer"]; it doesn't work, I have to put the same name CustomerID as for ParentCol, that's illogical to me. So why ? And how .NET will recognize on which child column the link is done then ? parentCol...

ado.net data service performance

Hi I am testing on ado.net data service. I just created web application with SQL server there is one table and about 900 rows in database table. I made a model only contains one entity After building application i just test to get all entities from web browser. but it takes about 5 or 6 minutes to get all data in internet webbrowser I...

How can i write stored procedures in my application using SqlHelper?

I'm looking at my options here. I would love to know how to write my stored procedures not in the SqlServer but in my app (DB Layer) using SqlHelper? Can anyone help? ...

SqlParamater updating values in a loop - side effects

I have a stored proc that takes one integer parameter. I am calling this in a loop (I would rather use an In but Stored proc is outwith my control). So I have one SqlParameter object who's value is updated each time round a loop. I have a vague memory of there being a side effect to this? Does this ring any bells? (.NET 2.0 / SQL Ser...

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds. I have one Stored Procedure Delete_OrdersByCustomerIds, which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string t...

Comparison of 3rd Party Oracle .NET Providers

I'm in the process of cleaning up an Oracle database application. In this application, performance and ease of access are paramount concerns. It has to get out of your way and let you get to the data in a free and uninhibited way. While doing that, it has to be very fast. When it can't be fast, it has to be multi-threaded so that it does...

Difference between ADO.NET 1.0 and 3.5 using RowFilter and strings?

I have recently been tasked with upgrading an application from .net 1.1 to 3.5 and came across a RowFilter on a DataView that had a different behavior between the two versions. Here is my code block in 1.1 that works in 1.1 but not 3.5. I get the following error trying to run this in 3.5 "Cannot perform '=' operation on System.String a...