ado.net

Bulk Copying and Deleting in OneTransaction

In C# application I like to copy the table data from one server(SQLServer2000) to another server (SQLServer2005). I like to copy the data in single instance and delete the existing data in the SQL Server 2000 table. I need to do all this(Bulk copying and Deleting) in single transaction. How to achieve this? Note: I am having two differe...

DBServerSyncProvider SelectClientIdCommand Sync Services Ado.Net

Hi, I want to use the DBServerSyncProvider's SelectClientIdCommand but i don't wan't to add more tables to my data base, i want to specifically define the clients id (as a long), something like this: long ClientIdentifier=540; SqlCommand ClientIdComm = new SqlCommand(); ClientIdComm.CommandType = CommandType.Text; ClientIdComm.Command...

How do you insert an entity for a many-to-many relationship? (entity framework)

If I a many-to-many relationship between Users and Roles and I have an instance of a User entity and several Role Ids can I insert a relationship between the two types of entities without having any other Role data and without doing a select on the Roles first? Update: I might not have been clear enough. I don't have an instance of a ...

Delete an object and all of it's related entities in Entity Framework

Hi, Does anyone know how to delete an object and all of it's related entities inside of EF without manually traversing the object graph and deleting each one? For example, I've got SalesOrder and SalesOrderDetails with a 1:N relationship between them. When I delete a SalesOrder, I want all SalesOrderDetails to be deleted automatically....

According to Msdn GridView.DataKeyNames must be set if we want to update database

Hi Use the DataKeyNames property to specify the field or fields that represent the primary key of the data source. You must set the DataKeyNames property in order for the automatic update and delete features of the GridView control to work. a) According to above quote Update should only be possible if DataKeyNames is set, and yet I...

ConflictOptions.OverwriteChanges VS ConflictOptions.CompareAllValues

hi 1) If you are using ConflictOptions.OverwriteChanges, then you also need to set GridView.DataKeyNames, else GridView won’t pass these parameters to the SqlDataSource and thus the Delete operation won’t succeed. But if you’re using ConflictOptions.CompareAllValues, then DataKeyNames doesn’t have to be set. Why? 2) But why nee...

Dataset Acceptchanges in SQL Server

I am loading my ADO.net dataset in by select query in command object. If I clear the dataset data with Acceptchanges will it delete the data in the sql server. If not Please let me Know how to do? ...

How do you access data that has been inserted using a ADO.NET transaction?

I'm trying to get the data that has been successfully input into the database via ADO.NET transaction. Once you've called trans.Commit() there doesn't seem to be a way of getting back the data that has been committed since all identity columns that were created during the transaction are 'virtual' since it is an offline dataset until co...

Transactionscope not working when two remote sql connections

I am using Two SQL Server connection object in my C# console application project. I need to do this in single transaction So I used Transactionscope (Distributed Transaction) I am not able to use the connection within the transactionscope It is displaying the error MSDTC on server is unavailable. How can I solve.... Both the one sql...

Sybase ASE ADO.net 2.0 provider?

I'm looking for an ADO.net 2.0 or later provider for Sybase database which seems to be known as Sybase ASE. To clarify, I'm interested in ASE, and not SQL Anywhere. Hopefully the provider will be included with the database, or free. I can find mention of an ADO.net 1.1 provider; that's not what I want. I can find mention of ODBC driver...

F#: How do I declare and use ByRef semantics on parameters?

I am wraping some SQL Stored Procs with in/out parameters. This of course means I have to do ugly stuff like declare my parameters as by reference and use mutables. How would I do this in F#? ...

How can you make an association without using all entity keys in entity framework?

I'm getting more and more frustrated with EF... I have a table called ExtendedField with: Record DocRef DocType Name Record is the primary key DocRef and DocType are foreign keys used to identify which Ticket they belong to Name is the key used by the "definition" table to define what the field actually is So basically I need 2 ...

DataGridView, ADO.NET, Binding, and Paging on the Client

I'm working on a WinForm application that has several queries that bring back approx 20000 records and then fills a DataTable, and binds that DataTable to a DataGridView. I want to allow the users to page through the grid 500 records at a time. What is the best way to do this? I want to do the paging on the client side. I see that the S...

To increase the timeout period

hi guys, I have to increase timeout period.Following is my code. Private Function GetConnectionInstance() As SqlConnection Dim objConn As SqlConnection Dim strConnection As String strConnection = ConfigurationSettings.AppSettings("conn") Try objConn = New SqlConnection(strConnection) Catch ex As Exception ...

Determine version of SQL Server from ADO.NET

Hi, I need to determine the version of SQL Server (2000, 2005 or 2008 in this particular case) that a connection string connects a C# console application (.NET 2.0). Can anyone provide any guidance on this? Thanks, MagicAndi Update I would like to be able to determine the SQL Server version form the ADO.NET connection object if poss...

ADO.NET Query optimisation

I have a bit of a strange one happening. The first query I got from running a profiler on a C# ADO.NET application. What it is doing is not as interesting as the way the parameters are being passed - This query is taking 250+ seconds to complete, but when I modify it (Query 1) by changing the way the parameters are passed (see Query 2), ...

SqlCommandBuilder and SQL Server Computed Columns - Error

What is the right way to avoid errors on INSERT and UPDATES with a SqlDataAdapter/SqlCommandbuilder when the SQL Statement used to SELECT has a computed column as one of the return fields? I get the error now that "The column Amount cannot be modified because it is either a computed column or is the result of a UNION operator". UPDATE:...

SQLDataadapter with Delete

I am just using select query and filling the dataset. and do some changes and I want to delete this entry in the dataset I am doing this foreach (DataRow dr in dsDatadata.Tables[0].Rows) { dr.Delete(); } ...

What are the best practices on formatting inline sql using ADO.NET in C#

I know there have been numerous questions here about inline sql vs stored procedures... I don't want to start another one like that! This one is about inline (or dynamic) sql. I also know this point has become more or less moot with Linq to SQL and its successor Entity Framework. But... suppose you have chosen (or are required by your...

Delete all rows in a datatable

I need to delete all the rows in a datatable (ADO.net). I dont want to use Foreach here. In one single how can I delete all the rows. Then I need to update the datatable to database. Note: I have tried dataset.tables[0].rows.clear and dataset.clear but both are not working Also I dont want to use sql delete query. Post other than th...