Tag: c#

Increment DateTime value based on total number of days

When a user adds a class they choose the start date and the end date of the class. I have been able to calculate the value between the end date and start date. I was able to create a For loop to insert a row into the Class table for each individual day the class […]

C# Entity Framework: making sure each entry is unique

I’m making an API call with C#, getting back a JSON, breaking it down into nested objects, breaking each object into fields and putting the fields into an SQL Server table. There is one field (OnlineURL) which should be unique. What is an efficient way of achieving this goal? I currently make a database call […]

SQL Server & C# – How can I check if a varbinary(max) file i'm uploading already exists in a table?

I am storing files in a table in SQL Server, in the following format: FileID – int (auto increment), FileName – VarBinary(MAX), FileData – VarBinary(MAX). What I would like to do is – by uploading a new FileName & FileData as parameters, return the first FileID where the FileName & File Data match, like so: […]

Entity Framework: Reusing foreign key

I’m refactoring someone else’s code involving EF6, code-first. I am trying to reuse database columns so that they are involved in more than one foreign key relationship. I am aware that by doing this, I am denormalizing my schema, but in so doing, it will allow me to make more direct relationships between models that […]

While calling SQL CLR procedure getting application pool size reached to Max getting error

While running asp.net application which is calling stored procedure hosted in sql server with sql clr returning below error:- An error occurred: A .NET Framework error occurred during execution of user-defined routine or aggregate “Procedure Name”: System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred […]

Insert data into SQL Server database from an Excel file

I’m trying to insert data to database using excel file. This code works fine for me. But I used this with windows form application. How can I change this code to WCF? I need to open Excel file using Windows Forms application and then pass the value to WCF service to insert data into the […]

How to get value of DataTable Row in C# asp.net

i am learning asp.net with c# by myself, and i have a problem with DataRows, in db i have users table and there is isadmin column which value is int, i want to redirect users to different page and admins to admin page, but the problem is all users redirects to admin page. Here is […]

LINQ query to find similar addresses

I have a table that store address. This table has multiple fields for address components such as address number, street name, direction, suffix, prefix, city, state and zip. (Edit: this address table having addresses that previously added by users. I expect they are from same town, city, state, and country. So I did keep city, […]

Why does trying to save a URL with a stored procedure only insert a point?

What I want is to save the url of an image, as I have seen the URLs are saved with two or four diagonals depending, so they are not taken as special characters and I already try those two ways, sending my URL string with more than one Diagonal attached. I have debugged and followed […]

Making database mdf work across different computers

I know this is kind of a stupid question but it gives me a lot of problems. Me and my partners in college projects have a lot of issues making the database mdf work when we send each other the visual studio projects. It gives us errors about the versions of sql server. Is the […]

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