Skip to content

Tag: c#

funny characters in Sql String

I have a query string that works fine if tableStr is for example MSFT. However, if tableStr is BRK-B, the query fails. How do I get around this? Answer Per MySQL Documentation, “The identifier quote character is the backtick (`)”. This means that if your table name has special characters in it, you need to surround the identifier with backticks.

How to export data to already existing excel sheet in C#?

I know how to create a new excel and export data into it. But how can I export data to an already existing excel which have some formats and data validation? Answer Take a look to NuGet library ClosedXML . I used it in the past and it’s really straightforward. Install the package in your solution: from VS: Tools >

EF Core transaction lifetime

We are using our select statement inside transaction scope because of concurrency concerns. The question is, if I put my transaction in using statement, do I still have to call Commit() method explicitly to be sure that the transaction is closed or Dispose() method will do the job? Here’s example code: Answer The official docs would be your best friend

Convert Sql to linq with groupby

I have view on which I use this request And it’s running sucessfully and get me this data How I need to write it using linq to get same data? I tried like this But on new HumpChartDto() {SpendBand = x.SpendBand} I got Cannot resolve symbol ‘SpendBand How I can solve this? Answer First, after grouping on SpendBand, you need

DataGridView selected row to check a checkbox

I am currently trying to check a checkbox dependent of the SQL data after selecting the row in a datagridview. I have gotten this to display text with TexBoxes, but cannot get it to check a check box. Yes = True No = False Any recommendations, would be very much appreciated. The table being displayed is bound by’binding source’ the

C# Multiple comboBoxes used in MySQL Where

Im trying to learn using MySQl with C# so im creating app that allow sorting and adding data to my tables. That is code that i use to show items selected only by my comboBox_1 value. But now i want to add 2nd comboBox and show data that meets both conditions. The problem is i have no idea how to