Tag: c#

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 […]

How to update data in activitypointer

How do I programatically update the subject in an activepointerbase? I’m getting a message that Create/Update method not allowed in Activity Pointer CRM 2011 I am getting an activitypointer record, and attempting to update it: var activityPointer = xrmServiceContext.ActivityPointerSet.FirstOrDefault(x => x.Id == myGuid); I then attempt to update it: activityPointer.EntityState = EntityState.Changed; organizationService.Update(activityPointer); And I […]

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