ado.net

How do I get all rows from ITEM table, which are children of a parent ITEM table row, where relationship is stored separately?

Hi, How do I get all rows from ITEM table, which are children of a parent ITEM table row, where relationship is stored separately? How can I do a join to do this? "get all rows from ITEM table, which are children of this specific ITEM table row, all child items from this parent item, where relationship is stored in separate RELATIONSH...

Is it possible to NOT map an assocation in ADO.NET entity framework

I'm working on a project that uses ADO.NET entity framework as the ORM framework for getting data in and out the database. This all works great, but there's one association that I don't want to map. At least I don't want the developers to navigate from Product to OrderItem using the association between them. Has anyone tried this scenar...

What is the time complexity of DataRow indexer?

What is the time complexity of accessing a column by its name in an instance of DataRow? object Foo(DataRow row, string columnName) { // What is the time complexity of the below line O(1) / O(n) / ? return row[columnName]; } ...

Executing DBCC Command From ADO.Net

I am trying to execute DBCC CHECK DB('MyDB) using ADO.Net, but how can I get the text returned by the command? I have tried the following: SqlCommand sqlCom = new SqlCommand("DBCC CHECKDB ('MyDB')", sqlCon); SqlParameter output = new SqlParameter(); output.Direction = System.Data.ParameterDirection.ReturnValue; sqlCom.Parameters.Add(ou...

How to use TransactionScope in a OpenSessionInView type pattern in a ASP.NET website

Hi What is the best way to implement a TransactionScope in a OpenSessionInView type pattern in a ASP.NET website? In the OpenSessionInView pattern a Http Module starts and closes a SqlTransaction, so that a single Transaction is used for the whole request rather than multiple Transactions. I would like to extend it to manage connectio...

Database abstraction layer in C# for MySQL?

I am trying to use MySQL 5 with C#. I downloaded MySQL driver on mysql.com and installed it. I can now connect to MySQL in C# with the following code. string ConString = "SERVER=192.168.10.104;"; ConString += "DATABASE=test;"; ConString += "UID=user;"; ConString += "PASSWORD=password;"; MySqlConnection connection = ...

Invalid Object Name: Beginner using the AdventureWords db from a class

I'm trying to learn some C#.net. I'm just trying to expose the AdventureWorks database included in my C# class via a web interface. Here's the setup: I've got a DropDownList in on my ASPX page with an id of tableNameDropDown. It gets populated on Page_Load like this: protected void Page_Load(object sender, EventArgs e) { ...

DbDataReader closing by itself?

I have the following code: var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection; DbConnection conn = entityConnection.StoreConnection; ConnectionState initialState = conn.State; List<Jobs> list = new List<Jobs>(); int id = 0; try { if (initialState ...

Quickly Testing Database Connectivity within the Entity Framework

[I am new to ADO.NET and the Entity Framework, so forgive me if this questions seems odd.] In my WPF application a user can switch between different databases at run time. When they do this I want to be able to do a quick check that the database is still available. What I have easily available is the ObjectContext. The test I am prefo...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named 'Tags'. I want to know if value 'programming' exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new OleDbCommand("SELECT * FROM table1 WHERE Tags='programming'", conn); OleDbDataReader = cmd.ExecuteReader(); What should I do next? ...

ASP.NET MVC with Model in Separate Assembly

I currently have a .NET solution I'm developing that involves several sub-projects, including an ASP.NET MVC project. My model has been separated into a separate assembly because I need to use it from the various other projects in the solution. My model consists of an ADO.NET Entity Framework entity model. I have decided to go with a si...

ADO.NET Data Services - Uploading files

I am trying to write REST web service through which our clients can upload a file on our file server. IS there an example or any useful links which I can refer for any guidance? I haven't seen many examples of POST operation using ADO.NET data services available. ...

Synchronising SQL database through ADO.Net

Hi, The problem that i'm having is how can i synchronise my datasets in my VS 2008 project to any changes in the database. As you know we read data from the db into the dataset which is disconnected, now lets say 1 minute later something updates the data in the database. What i want to do is after a set time interval check the db for...

How to DataSet.Fill with DateTime values defaulting to DateTimeKind.Utc?

I have an application which would read data from SQL and send it via WCF to a client app, in a manner similar to this: SqlDataAdapter da = new SqlDataAdapter( cmd ) DataSet ds = new DataSet(); da.Fill( ds ); return ds; All the date/times are stored in the database as UTC. What I noticed is that if clock on computer running the applica...

How to get id of last inserted row with ADO.NET Entity Data Model

This is my example code: var klienciToAdd = new klienci(); klienciToAdd.nazwa = collection["nazwa"]; klienciToAdd.miejscowosc = collection["miejscowosc"]; _db.AddToklienci(klienciToAdd); _db.SaveChanges(); ...

Many to many relationship with ADO.NET Entity Data Model

I've created many-to-many relationship with ADO.NET with extra order fields in the middle table. So I have... Customers -customer_id -customer_name Orders -order_id Customers_to_Orders -customer_id -order_id -seq And now I don't really know how to add new orders to customers with specyfing order, any suggestions? ...

C# and ADO .NET entity data models with LINQ associations and entities for the same table

My database tables are as follows: Users (UserId, Name) Friends (UserIdFrom, UserIdTo) I also have an ADO .NET entity data model that describes these tables. My .NET entity data model has an entity named Users and an association for that entity called Friends that corresponds to the Friends table. My question is that I want to get a ...

Dynamically sorting a DbDataReader using LINQ

I am very new to LINQ and have a class method, which when called, returns a DbDataReader object. How would I sort this dynamically using a LINQ query expression where the sort expression is provided as a string (e.g. "LastName DESC") ...

Is it possible to set the Instance Name of ado.net Performance Counters?

We are running an asp.net web application which uses ado.net to connect to the database. I'd like to monitor the ado.net performance counters. Right now im using Control Panel -> Performance to do so. But the instance names seem to change when the Application is restarted. So the logging no longer logs the counters. What is the best way ...

Recover from SQL batch-abort errors inside a transaction? Alternative?

I'm looking for a way to continue execution of a transaction despite errors while inserting low-priority data. It seems like real nested transaction could be a solution, but they aren't supported by SQL Server 2005/2008. Another solution would be to have logic to decide if an error is critical or not, but it would seem that's not possibl...