Tag: c#

FlyWay with interdependent databases

I’ve seen posts about FlyWay handling multiple databases but it all seems like it is for databases that are independent. As I understand it, FlyWay can only handle one database per instance so creating/cleaning database schemas are completely independent. Multiple datasources migrations using Flyway in a Spring Boot application Our problem probably stems from bad […]

Use of Async / Await to write to SQL using three Tasks

I have a program that reads from 7 different PLC’s at generally the same time using background threads. Using the 7 different reads, I am hoping to write to three different SQL tables. public static async void readReady() { if (Read1_complete && Read2_complete && BCS_complete == true) { await Task.Run(() => W1_SQL_Write.SQL_Write_Enabled()); } if (Read3_complete […]

FMTONLY in SqlBulkCopy.WriteToServer

When calling SqlBulkCopy.WriteToServer, I can see a bunch of SET FMTONLY ON and SET FMTONLY OFF However https://msdn.microsoft.com/en-us/library/ms173839.aspx says: Do not use this feature. This feature has been replaced by sp_describe_first_result_set (Transact-SQL), sp_describe_undeclared_parameters (Transact-SQL), sys.dm_exec_describe_first_result_set (Transact-SQL), and sys.dm_exec_describe_first_result_set_for_object (Transact-SQL). Is this still the correct .Net method to call for bulk inserts?

Asynchronous fire and forget in c#

Currently I am about to develop logging for a c# application into a SQL server table. I have a designated class called Logger that has a static method writeToLog(). I just want to call that static function without block the calling thread. How is this possible in C# clean and fast? The functions don’t return […]

Lost order after Take/Skip in Entity Framework

I have a query in EF which takes information from various tables. I would order on the basis of certain fields in this way: query = query.OrderBy(x=>new {x.Cde_Conto,x.Data_1,x.Data_2}); If i do query.TotraceQuery(); in sql server i get the desired result. but I have to do an extra step..given that i have to show only a […]

Pass object parameter to stored procedure by SqlHelper

I have a SQL table like this: ID is Identity column. And I have a class for this table in ASP.Net project like this: public class Topic { public int ModuleID { get; set; } public string Name { get; set; } public string BodyHTML { get; set; } } Also I have a stored […]

Save listbox to SQL Server database using Linq

I am trying to save list of items shown in a listbox in my service public class MyItem { public string DisplayVersion { get; set; } public string DisplayName { get; set; } public string Publisher { get; set;} } public List<MyItem> GetListapp() { List<MyItem> items = new List<MyItem>(); string registry_key = @”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”; using (RegistryKey […]

Connecting to Azure SQL Server with Qt on Linux

I am trying to connect to a Azure SQL Server database with Qt on Linux but I have not could make it. I tried some like this: Connection to SQL Server with qt but the connection is never opened. My code is so simple: QString connectionTemplate = “DRIVER={SQL SERVER};SERVER=%1;DATABASE=%2;”; QString connectionString = connectionTemplate.arg(“tcp:my-database.database.windows.net,1433”).arg(“my-database”); for(int i […]

Retrieve a query from a SSIS SQL task via C#

I am looking for a way to programmaticly pull the all SQL statements from hundreds of dtsx files. I am already pulling the connection string and type by creating a package instance as seen below. I’m hoping for a solution that will allow me to access a SQLTask object via the package Application app = […]

How can i convert time to minutes using Sql queries e.g “02:30:05' to 150.5 minutes

I am working on a billing system and its based on time-in and time-out. Rate is R5 per 30 minutes charged to users for loaning an item. I managed to get the Time difference and got time as “02:30:05” now how can i convert this time to minutes and have “02:30:00” = “150 min” so […]

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