SQL paramaterisation in C#, using SQL declared variables

I have the following SQL query which I am sending from a C# program: DECLARE @id as int SELECT @id = max(fault_catagory_ident) FROM fault_catagory_list INSERT INTO fault_catagory_list (…

To add dropdownlist using a secondary table column values

I have to add a dropdownlist to my existing project “moviesite”, i have a primary table moviestable for adding, edit delete movies. now added a new table Genre to add movieGenre. second …

Query not executing as expected, returns -1 no matter what

I’m working on a user login system for a semester final. I am using C# in Visual Studio with ADO.NET. I have a query that I use on a database table named Credentials: SELECT * FROM Credentials WHERE …

How do I convert this SQL into LINQ?

How Do I convert this sql query: select * from Trades where tradestatus = 1 and tradetype = 1 and maturitydate < GETDATE() and referenceId not in (select referenceid from Trades where tradetype = 2)…

How to convert SQL query to Linq in Entity Framework 6?

How can I convert this SQL query to a linq expression? Select distinct Clients.Id From Clients Join Orders On Clients.Id = Orders.ClientsId and Orders.Date < DATEADD(DD, -Clients.Term, CAST(…

Adding text and image to database with C# and SQL

The following windows form application takes an input for name, age, gender, description, and an image. However when clicking the “Save Information” button the following exception error …

How to map from query string to SQL query? [closed]

So I have as search endpoint [HttpGet(“search”)] public async Task Search([FromQuery] string query) that returns a list of users from the cosmosDb based on email, name …

PostgreSql and EF – Getting ‘duplicate key’ error while doing ‘ToDictionary’ after grouping

Here is my query. UserName column is citext, having non-unique index on it. var logs = Db.Logs .GroupBy(x => x.UserName) .ToDictionary(g => g.Key, g => g.Max(m => m….

How to prevent MySql Injection in dynamic where?

I have an API in my C# WEBApi project which return some items from my MySQL DB. The data to return has a visibility set in a table and the params set in the API call says which kind of data should be …

Delete row in datagridview and database with C#

I made a database and a program with a datagridview to show the database content. Now I want to make a button to let users delete a row and delete it also in the database. I tried the following …