Tag: c#

SqlDependency and the ACID Principle

I intend to use the SqlDependency class to invalidate my MemoryCache using the CacheItemPolicy and SqlChangeMonitor classes. I understand that the underlying technology uses Service Broker and sends notifications to my code when the data that my query retrieved has changed. My question is; do changes that would affect multiple SqlDependency instances get handled in […]

Calling a linked server fails after a snapshot connection has been disposed

We have a C# application using ADO.NET and an SQL-Server with SNAPSHOT Transaction Isolation Level. This is ‘as is’ and unfortunately cannot be modified. Now we need insert stuff on a linked server. We execute the following code (reduced to illustrate the problem): // Create a snapshot Transaction and close the connection using (var con […]

DefaultSpatialServices.GeographyPolygonFromText Error

I recently installed VS2015 on a new machine and cloned my project from Git Hub. When I try to run this code: DbGeography.PolygonFromText(this.LATLNG, 4326); //latlng is text I get this error System.NotImplementedException was unhandled I went to nuget and installed Microsoft.SqlServer.Types But this didn’t help. I have installed Sql Server 2016 dev on my machine […]

Insert on @@RowCount=0 for Update: Timed Out in C#

I am using C# along with SQL Server (tried different version, so version doesn’t matter). I write a query as UPDATE tblSalesVerbiage SET SalesID = 1, Message = ”, SpanishMessage = ”, TitleName = ‘VerbiageOnline6’, isEditable = 0 WHERE TitleName = ‘VerbiageOnline6’ AND SalesID = 1; IF @@ROWCOUNT = 0 BEGIN INSERT INTO [tblSalesVerbiage] (SalesID, […]

Search on variable fields with multiple match types

Question: How can I build a search like this in .NET with SQL Server? Notice the “Score”, and “Max” columns. (These are not my terms. “Max” appears to represent the maximum value for a query, and “Score” represents the value achieved by the search, which is less than or equal to the “Max”.) This is […]

Publish C# application with SQL Server database

My application does basic CRUD operations over an external .mdf file. The database file is created separately in SSMS. On my PC, everything works perfectly fine. When I install it on someone else’s computer, it refuses to connect to the database. The other PC also has the same database at the exact same location. The […]

How to backup SQL localDB with SMO

I am trying to backup a SQL localDB database using SMO but with no success. What is wrong with my code? progressBar.Value = 0; SaveFileDialog sfd = new SaveFileDialog(); string stringCon = @”Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\whdb.mdf;Integrated Security=True”; sfd.Filter = “Database backup files (*.bak)|*.bak”; sfd.Title = “Create Database Backup”; sfd.FileName = DateTime.Today.ToString(“ddMMMyyyy”) + “.bak”; if (sfd.ShowDialog() == DialogResult.OK) […]

How can I increase connection timeout of SQL connectionstring?

This question already has an answer here: Connection timeout for SQL server 3 answers

Entity Framework: Seemingly random SQL Server connection error

I have an application using Entity Framework (database first) on top of a SQL Server database. The application is configured with default settings, like I’ve built all of my applications for the past couple of years. However, with this particular application, when running on my windows server, I’m getting the following error now and then […]

Post JSON data to Sql Server report services 2016 with web api

I am trying to post JSON data from web app to SQL Server reporting services 2016. So far I was able to create stored procedure in SQL server to read file with json data and convert it to table format. In SSRS, I am using that stored procedure as data set for report. Now I […]

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