Tag: .net

windows service integration with sql using ado .net

**public static void göster() { SqlConnection connection =GetConnection.GetConnectionObject(); //TODO parametreleri command.parameters yoluyla alsın SqlCommand command = new SqlCommand(); command.CommandText= “select * from windowsserv”; command.Connection = connection; if (connection.State != ConnectionState.Open) connection.Open(); Console.WriteLine(“Connection opened”); SqlDataReader rdr = command.ExecuteReader(); while(rdr.Read()) { ——————> Console.WriteLine(rdr[0].ToString()+”–“+rdr[1].ToString()); } if (connection.State != ConnectionState.Closed) connection.Close(); Console.WriteLine(“Connection Closed.”); Console.ReadLine(); } Hi all, This is […]

Custom Execution Strategy for Connection Resiliency With Entity Framework 6 and MS-SQL Server

I already developed one application with the EF6 and MS-SQL Server. Everywhere in my application I wrote the code like below where I needed to Insert, Update or delete the data from the table: Code: using (DemoEntities objContext = GetDemoEntities()) { using (TransactionScope objTransaction = new TransactionScope()) { Demo1(objContext); Demo2(objContext); // Commit the changes in […]

Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths – why?

I’ve been wrestling with this for a while and can’t quite figure out what’s happening. I have a Card entity which contains Sides (usually 2) – and both Cards and Sides have a Stage. I’m using EF Codefirst migrations and the migrations are failing with this error: Introducing FOREIGN KEY constraint ‘FK_dbo.Sides_dbo.Cards_CardId’ on table ‘Sides’ […]

C# – create new SQL Server database results in error

I’m trying to create a new database on my server programmatically using Microsoft.SqlServer.Management.Smo, but it always fails to create the database: Server svr = new Server(new ServerConnection(@”.\SQLEXPRESS”)); Database db = new Database(svr, “TESTDB”); db.Create(); I get this error at db.create();: An unhandled exception of type Microsoft.SqlServer.Management.Smo.FailedOperationException’ occurred in Microsoft.SqlServer.Smo.dll The server’s name is correct, and […]

How to execute the script through cmd or powershell generated by EF Migrations

Earlier, i was using EF AutomaticMigrations in my project. It was still in Development Environment only. Now, we are going for the production environment and i want to use code-based migrations. I have generated an InitialCreate.cs migration file using add-migration Then, i made some changes to my model and added a new migration file add-migration […]

SqlDataReader Timeout expired odd error

Been fighting an aggravating bug with SqlDataReader. This old code is in Visual Basic using .NET Framework 3.5 on an AWS server running Windows Server 2012. Database is Msft Sql Server running in Amazon’s RDS environment. We started seeing this error in our log: “Timeout expired. The timeout period elapsed prior to completion of the […]

Connection String Dynamic C#

I am using this connection string. It is working. I can select, insert using it. But this method is not dynamic. static string cs = @” Data Source = (LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SayHellox)\Documents\Visual Studio 2015\Projects\R Accounts\R Accounts\User_DB.mdf;Integrated Security = True”; But when i use this method. It can select, but when i use insert query it gives successfully […]

Upgraded .net webapp can't open connection to database

I have an old .net 1.0 webapp that needs a bit of maintenance done on it. I’ve used the auto-upgrader to upgrade it to .net 3.5 (and also later tried 2.0) but now it can’t connect to the database. On the surface this looks like a noob connection-string problem, but I’m thinking it’s more likely […]

Problem with handling COM events in VB.NET

I’m calling the SQLDMO 8.0 COM library from VB.NET (using a PIA I generated with tlbimp) in order to backup a database with percentage completion notification: Dim server As SQLDMO.SQLServer = Nothing Dim backup As SQLDMO.Backup = Nothing Dim restore As SQLDMO.Restore = Nothing Dim backupAbortable As Boolean Dim restoreAbortable As Boolean Try server = […]

Disconnected or Connected Architecture

Is a disconnected architecture too complex for the following story line? I’d be grateful if anyone could share any opinions or experiences that they may have. There is a business application that runs inside the office network which consists of a desktop application and a SQL Server database. Some of the data is exposed to […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.