ado.net

How to get identities of inserted data records using SQL bulk copy

I have an ADO.NET DataTable with about 100,000 records. In this table there is a column xyID which has no values in it, because the column is an auto-generated IDENTITY in my SQL Server database. I need to retrieve the generated IDs for other processes. I am looking for a way to bulk copy this DataTable into the SQL Server database, an...

Strange problem with DataReader?

I am facing a strange issue with DataReader. I am using OdbcClient with a legacy rdbms system. I am sending follwing command to the database. select Col1, Col2, Col3 from Table1 where Col2 = 'Val1'; However in certain cases when I iterate it through DataReader as shown below. IDataReader reader = cmd.ExecuteReader(); while(reader.R...

Internal classes with ADO.NET Entity Framework

I'm using Entity Framework for creation of my Data Access Layer and I want for all of my classes to be internal. I know it is possible to manually assign it in the designer for each class. UPDATE I found that my initial statement But looks like it also requires to set internal modifier for each single property in every class! I hav...

how can I future-proof migration of a ADO.net local data layer to a future web based interface (web-service or REST)?

Hi, BACKGROUND: I am working on a .NET WinForms application now (C#) with an ADO.net database for the data layer. QUESTION: How an I develop this now such that it would be easy to migrate to a model where the data layer is abstracted via a HTTP web-service or REST interface? For example would just use of a standard C# interface with...

Inserted records are automatically sorted in MS Access database C#.NET

Hi, When insert data using OLEDB Jet provider, the data are inserted properly, but the order in which I have inserted is not kept as is. Instead it's automatically changing the order. How to make the inserted records in the same order ?? ...

why DbCommandBuilder (Oracle) produces weird WHERE-clause to UpdateCommand?

I have a table HolidayHome in oracle db which has unique db index on Id (I haven't specified this in the code in any way for adapter/table/dataset, don't know if i should/can). DbDataAdapter.SelectCommand is like this: SELECT Id, ExtId, Label, Location1, Location2, Location3, Location4, ClassId, X, Y, UseType FROM HolidayHome but...

ADO.net, Check if ObjectContext is writeable

I have an embedded database in an asp.net mvc project. If I try to write to the file, I sometimes get a write failed exception because the SQL Server can't write to the file. How can I check an ObjectContext, if its writeable, without actually writing something to the database? ...

ADO.NET 2.0 under Mono examples ?

I've seen that ADO.NET 2.0 is compatible with Mono but I can't found any example of that in the web ? ...

Connect to SQL Server Compact Edition in SSIS

Till now I've been exporting data INTO the SQL Server CE database, but now in SSIS I'm attempting to source data that was inserted in a previous step of the import. The SSIS fails during validation with the following error Error: Microsoft.SqlServer.Dts.Runtime.DtsCouldNotCreateManagedConnectionException: Could not create a managed con...

is it possible to add DataRelation to DataSet if child table contains rows that have no parent in parent table in C# / ADO.NET 2.0

If I fill the DataSet with DataAdapters that select all rows from Orders and Customers and call: private void CreateRelation() { // Get the DataColumn objects from two DataTable objects // in a DataSet. Code to get the DataSet not shown here. DataColumn parentColumn = DataSet1.Tables["Customers"].Columns["CustID"...

Dealing with huge SQL resultset

I am working with a rather large mysql database (several million rows) with a column storing blob images. The application attempts to grab a subset of the images and runs some processing algorithms on them. The problem I'm running into is that, due to the rather large dataset that I have, the dataset that my query is returning is too l...

Notification in case of data changes in SQL and Oracle

I am in the process of building a system where I need to notify a Window Service in a .net based application in case of any change in the DB table (Insert , Update , Delete). I know this can be done with the ADO.NET Events in SQL. Is there any common solution for Oracle and SQL which can provide these kind of notifications. This needs to...

Creating an Excel file using .NET (C#) - Problems with columns headers!

Hello, I want to create & fill a .xls file using ADO.NET or LINQ, but I do not want to have the columns names in the first row. I just want to insert rows starting in row no. 1. I know I have to insert colums first, but... is there a way to 'hide' those columns headers? The problem is that, in first row of my spreadsheet, I must have ...

How can I connect to a principal database when a failover occurs in SQL server 2005?

How can I connect to a principal database when a failover occurs in SQL server 2005 using TSQL.....after failover a pricipal database becomes mirror but still how can i connect to the new pricipal using SQL command ...

How update DB table with DataSet

I am begginer with ADO.NET , I try update table with DataSet. O client side I have dataset with one table. I send this dataset on service side (it is ASP.NET Web Service). On Service side I try update table in database, but it dont 't work. public bool Update(DataSet ds) { SqlConnection conn = null; SqlDataAdapter da = null...

Strange behaviour of code inside TransactionScope?

We are facing a very complex issue in our production application. We have a WCF method which creates a complex Entity in the database with all its relation. public void InsertEntity(Entity entity) { using(TransactionScope scope = new TransactionScope()) { EntityDao.Create(entity); } } EntityDao.Cr...

DataSet.GetChanges() return null C#

Hi I need advice. I try this DataSet ds = new DataSet(); ds.AcceptChanges(); //edit table in ds ds.Tables[0].Rows.RemoveAt(0); //get changes DataSet ds2 = ds.GetChanges(); but ds2 is null, why? ...

Throwing exception vs checking null, for a null argument

What factors dictate throwing an exception if argument is null (eg if (a is null) throw new ArgumentNullException() ), as opposed to checking the argument if it is null beforehand. I don't see why the exception should be thrown rather than checking for null in the first place? What benefit is there in the throw exception approach? This...

Limit Access Using WCF Data Services

I've been checking out WCF Data Services today and it looks great - but so far I haven't been able to find much about security -- specifically, limiting access to the services based on the connecting account. In SQL you have some accounts that have read only access (and those are sometimes limited to a few tables) but so far in WCF Data...

.net Windows form binded with data, too slow

I have a windows application in which a form is binded with the data. The form loads slowly because of large data. I am also showing paging in form to navigate through the records. How to increase the performance? ...