ado.net

how can I add a custom non-DataTable column to my DataView, in a winforms ADO.net application?

Hi, How could I (/is it possible) to add a custom column to my DataView, and in this column display the result of a specific calculation. That is, I currently have a dataGridView which has a binding to a DataView, based on the DataTable from my database. I'd like to add an additional column to the dataGridView to display a number whic...

SqlCommand & SqlConnection

Hi All, If I have something like this: using( SqlCommand sqlCmd = CreateSqlCommand( "load_collection_get", false ) ) { // Code } CreateSqlCommand looks like: public static SqlCommand CreateSqlCommand( string storedProc, bool transaction ) { SqlCommand sqlCmd = new SqlCommand( storedProc, sqlHelper.GetConnection() ); ...

An entities that create entities using Entity Framework

How do you handle the case when an entity needs to create, in one of its methods, other entities? My problem is that since each individual entity doesn't have access ObjectContext object, that one with the AddToBlahs() methods, it cannot do it. For example, having a Site model that has a UpdateLinks() method that is supposed to create L...

one-to-one relationships in Entity Framework 4 v2 with POCO

I've been looking for an example about how to build an one-to-one relationship in EF4v2 with POCO's. I found a lot of examples that show only how to create one-to-many or many-to-many. Do you have any resource about it? ...

Using ADO 3.5 to Import Data From Excel into 64-bit Application

Hi, I am currently developing a 64-bit C# application that needs to import its data from an Excel spreadsheet. I have heard that the best way to do this is by using ADO data connections. However, I have read (and experienced) that in order to make this work, I must be writing a 32-bit application as there is no OleDb odbc driver for ...

ADO.net Question - How can I update a column in a Row of a DataTable with RowChanged without triggering infinite loop?

Hi, How can I update the column value (programmatically) in a Row of a DataTable via use of the RowChanged event, without triggering infinite loop? (which I currently get) Note I do not want to use the DataColumn.Expression property. For example the following gives me a recursive loop and stack overflow error: DataColumn dc = new...

LINQ to SQL vs ADO.NET - which is faster?

Since LINQ to SQL basically is a layer on top of ADO.NET it requires some translation. Does this mean that using ADO.NET directly is faster than LINQ? Or is the difference so small that it is irrelevant? ...

SQLCE qand C#; Populate a DataSet with ALL the Tables from a SQLCE DB

How would I Populate a DataSet with ALL the Tables from a SQLCE DB. Is this possible in ONE SQL select statement? I know that I can call seperate select statements with the names of the table I need data from but I need a generic solution that just dumps all the tables from the SQLCE DB into a Dataset. Thanks ...

MS Access UPDATE QUERY Problem

Hi, I am trying update my table from c# ado.net with this function.I am using for update process stored prosedure in access db.Everything working fine in MS Access side.Giving parameters to access and its update well.But when i tried this in c# ado.net side not giving any error but its not updating.I have got so many working stored pro...

Check Constraints on DataRow Add

DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("ValueOne",typeof(string)){AllowDBNull = false}); dt.Columns.Add(new DataColumn("ValueTwo",typeof(string)){AllowDBNull = false}); DataRow row = dt.NewRow(); row["ValueOne"] = "Test1"; if (dt.Rows.CanAdd(row)) { dt.Rows.Add(row); } Is ...

How to delete an asociated object in Entity Framework without having access to the object context

Having two models, Site and Link, where a site has many links, how do I delete a link from inside a method of Site, which doesn't have access to the object context? I've tried something like: public void DeleteFirstLink() { var link = LinkSet.First(); LinkSet.Remove(link); } but it seems that is not really deleting the link, ...

How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?

We have code like: ms = New IO.MemoryStream bin = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bin.Serialize(ms, largeGraphOfObjects) dataToSaveToDatabase = ms.ToArray() // put dataToSaveToDatabase in a Sql server BLOB But the memory steam allocates a large buffer from the large memory heap that is giving us prob...

Handling database connections when calling CRUD methods on existing Data Access Layer

The scenario is a user of a .NET web application can select a text file, each line will be imported as a new record in an SQL Server database. The project has an existing data access layer, which opens SqlConnection for each method in the DAL. This works fine for individual records, for example when the user uses the web forms to insert...

How to Stream data from/to SQL Server BLOB fields?

For the background to this question, see “How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?” that now has a large bounty on it. I wish to be able to use a Stream object to read/write data to/from a BLOB field in a SQL Server row without having to put the all the data in...

Creating an Excel Sheet with ADO.NET (OleDb) --> What DataTypes are Supported?

Hi I try to create an Excel (2003) Sheet with ADO.NET (OleDb). I was able to create the Sheet with an OleDbCommand: var cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;..."; var cnn = new OleDbConnection(cnnString); var cmd = cnn.CreateCommand(); cnn.Open(); cmd.CommandText = "CREATE TABLE MySheet (ID char(255), Field1 char(255))"; cmd....

Changing CommandTimeout for nHibernate Session

How to change command Timeout for a session in nHibernate. I know it can be done in App.Config but I want to increase the default value only for one business operation. ...

Asp.net finding and downloading file

I have File Upload form which users use to upload certain files on the server. The files are uploaded in path that look like this. "G:\\VS\\Ticketing System2\\UploadedFiles\\" + ProjectId + "\\" + ticketId + "\\TicketFiles\\"; After that I have a repeater which displays some data and have a hyperlink. I want to name the hyperlink"Down...

ADO.NET Entity Data Model - Adding custom properties.

Hello, I am new to using the ADO.NET Entity Data Model tool. I have a table in my database that has three properties (FirstName, LastName, Age). I need to add a field to this entity called IsChosen. However, I cannot add this column in the database. How do I add custom properties to entities generated through this tool? Thank you! ...

ADO.NET Entity Framework Quirk

Hi, When I run the code below, it works int charId = int.Parse(Request.Params["charId"]); EveFPT ctx = new EveFPT(); var theCharQuery = from a in ctx.tblChars where a.id == charId select new { ...

Microsoft OracleClient Provider and Positional Parameters Binding

Does anyone know how to get the Microsoft OracleClient Provider to support binding parameters by position, currently it does that only by Name and there does not seem to be any option to specify to use positional parameters. I know that Oracle's ODP.NET supports positional parameters, but i want this in Microsoft's provider. ...