ado.net

SQL Server truncate table - drop and recreate FK constraints script

走远了吗. 提交于 2019-12-21 21:32:57
问题 I'm writing small application (in c#) which helps me to truncate tables in SQL Server 2005/08. In order to truncate table I think I need to do this: drop all FK constraints from table, truncate the table, recreate all previously deleted constraints. Can someone help me to create such a script, or point me where I can find some clues? Regards 回答1: Well, you could do this from your application: run a SQL command on your existing database to find all foreign key constraints from that list of

Lightswitch is slow, ADO.NET Entity Framework/Domain Service/WCF RIA Service

亡梦爱人 提交于 2019-12-21 21:26:35
问题 I'm developing an Lighswitch application in VS2012 with an external SQL Server 2008. I'm using a WCF RIA Service to fetch my data, using these techniques: http://www.c-sharpcorner.com/UploadFile/raj1979/how-to-use-wcf-ria-service-in-lightswitch-2012/. My main table contains some columns with static data and about 5 columns with foreign keys. The static data columns loads instant but all the foreign properties takes 3-5 secs to load on a screen with ~100 rows. This is not acceptable.. The

Does SqlDataAdapter open its own connection?

南楼画角 提交于 2019-12-21 20:54:06
问题 Does SqlDataAdapter open its own connection? private DataTable UpdateOxa(ProductCatalogSyncData syncDataModel, string connectionString) { var ds = syncDataModel.SyncDataSet; var dtResults = new DataTable("BillingIds"); var syncConfig = syncDataModel.XDataMapping; string EntityName; string queryString = @" IF OBJECT_ID('#CRM2Oxa_ID_MAPPING') IS NOT NULL DROP TABLE #CRM2Oxa_ID_MAPPING CREATE TABLE #CRM2Oxa_ID_MAPPING( [EntityName][nvarchar](1000) NULL, [TableName][nvarchar](1000) NULL, [CRMID]

Entity Framework Foreign Key Mapped to Same Table

99封情书 提交于 2019-12-21 20:33:53
问题 This is not a duplicate of this post although the title is very similar. I am using EF4 with MSSQL Express 2008 R2 on VS2010. A simplified version of my schema is as follows: Table [Team]: Id (PK) Member1 Member2 Table [Person]: Id (PK) FirstName [Team].Member1 and [Team].Member2 are foreign keys pointing to [Person].Id. When generating the .edmx via VS2010, the navigation properties under [Team] become "Person" and "Person1" despite giving distinct names to the FKs inside SQLServer. Is it

Does Firebird ADO.NET 4.10.0.0 Data provider work with Firebird 3.0?

给你一囗甜甜゛ 提交于 2019-12-21 20:22:30
问题 I'm currently trying to get my ASP.net 4.5 project connecting to the recently release Firebird 3.0. I'm using Visual Studio 2015 Community edition, Firebird 3 (64 bit), and used NuGet to get the ADO.NET 4.10.0.0. However, when I try to connect, I get an exception withe the following message: this.connect.ServerVersion threw an exception of type 'System.InvalidOperationException' Some other messages that I get: Message: "The connection is closed" Source: FirebirdSQL.Data.Fierbird.Client

Converting a COMPLEX stored procedure into C# & ADO.Net

旧时模样 提交于 2019-12-21 19:59:58
问题 This is NOT a question on whether SPs are good or bad. Or whether writing SQL statements in C# is good or bad. Very soon we start work on a new project which is a typical inventory/billing management system. This will be developed using .Net and C# as the language. The database is not yet finalized. Use of stored procedures is NOT ALLOWED in this application and it will have medium to complex database operations. So logic that I could have easily written using and SP, is now something I will

C# and PostgreSQL

橙三吉。 提交于 2019-12-21 19:54:10
问题 Can any one show me working example of using cursor returned from PLSQL to c# code? I found many examples showing how to fill dataSet with returned data but I cannot find how to use that cursor with DataReader, as a result I have {unnamed portal}. NpgsqlTransaction tr = (NpgsqlTransaction) Connection.BeginTransaction(); NpgsqlCommand cursCmd = new NpgsqlCommand("someStoredProcedure(:inRadius)", (NpgsqlConnection) Connection); cursCmd.Transaction = tr; NpgsqlParameter rf = new NpgsqlParameter(

How can I make DataTable enumerable?

£可爱£侵袭症+ 提交于 2019-12-21 17:39:21
问题 I cannot use AsEnumerable() on DataTable, I'm using C# 3 but I'm just targeting 2.0 framework (LINQ capability is courtesy of LINQBridge). Is there any way I can make DataTable enumerable without using Select() ? bool isExisting = (bdsAttachments.DataSource as DataTable).Select().Any(xxx => (string)dr["filename"] == filename); Update: I wanted it to make it look like this: bool isExisting = (bdsAttachments.DataSource as DataTable).AsEnumerable().Any(xxx => (string)dr["filename"] == filename);

.NET State of DB Connection

↘锁芯ラ 提交于 2019-12-21 17:01:58
问题 When you manage database connection manually you always open and close it. Sometimes you need to check if connection has some state before do some action. A classic situation is check for not Closed state before close connection. Something like if (connection.State != ConnectionState.Closed) connnection.Close(); As MSDN states the ConnectionState is enum WITH FLAGS. It means that connection state can have different states at same time. May be Broken+Closed or something else... If you

List of SQL Server errors that should be retried?

僤鯓⒐⒋嵵緔 提交于 2019-12-21 16:57:03
问题 Is there a concise list of SQL Server stored procedure errors that make sense to automatically retry? Obviously, retrying a "login failed" error doesn't make sense, but retrying "timeout" does. I'm thinking it might be easier to specify which errors to retry than to specify which errors not to retry. So, besides "timeout" errors, what other errors would be good candidates for automatic retrying? Thanks! 回答1: You should retry (re-run) the entire transaction, not just a single query/SP. As for