Tag: c#

SQL Bulk copy versus Structured Table Insert

Just wondering if there are any performance differences between structured table inserts and bulk copy. Any experience or ideas which might be performant before I start implementing it. I am using Spring.net for the database layer calls. Sql Bulk Insert using (SqlBulkCopy bulkCopy = new SqlBulkCopy(this.connectionstring) { bulkCopy.DestinationTableName = “BulkDataTable”; bulkCopy.WriteToServer(dataTable); } Sql Structured type […]

How to get the Identity values in SQL BULK COPY?

I have to get the IDENTITY values from a table after SQLBULKCOPY to the same table. The volume of data could be thousands of records. Can someone help me out on this ?

Seeding my DB with Entity Framework DateTimes

I am using Code First Workflow with Entity Framework 6.1.3 and I am trying to seed my database with some data by adding a migration like so: public partial class SeedDatabaseWithBusinesses : DbMigration { public override void Up() { Sql(“INSERT INTO Businesses (GooglePlaceId, Name, CurrentMenu, LastUpdated)” + ” VALUES (‘googlePlaceIdHere’, ‘Examples Businesses Name’, ‘Fish and […]

How to update a value in local SQL Server database

In my program I want the user to have the option to change the value (price in my example) in a local database, that I created. I’m having a problem with it. The connection works fine and it debugs well and even shows the message that “saving ok”, but it doesn’t change at all in […]

why contained database user needs Persist Security Info=True

I have a database where I created a contained user and I needed to connect to my web app using that user. I have always been able to connect to the web app with a standard user having Persist Security Info=False. However, the only way I was able to connect with the contained user was […]

Multiple Where vs Inner Join

I have a filter where depending on the user selection I conditionally add in more Where/Joins. Which method is faster than the other and why? Example with Where: var queryable = db.Sometable.Where(x=> x.Id > 30); queryable = queryable.Where(x=> x.Name.Contains(‘something’)); var final = queryable.ToList(); Example with Join: var queryable1 = db.Sometable.Where(x=> x.Id > 30); var queryable2 […]

Storing files in SQL Server database

I want to store files in my SQL Server database by C# which I have done it without problem. This is my code: byte[] file; using (var stream = new FileStream(letter.FilePath, FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(stream)) { file = reader.ReadBytes((int)stream.Length); letter.ltr_Image = file; } } LetterDB letterDB = new LetterDB(); id […]

SQL Server UDF SQLCLR Call Converts Characters Into Question Marks

I’ve found nothing on Google or SO that quites lines up with my issue. In SQL Server, I have a scalar function (we’ll call it dbo.MySqlStringFunction). What this function does is call a utility written in C# that calls an ASP.Net view and returns the HTML as a SqlString. The function definition in SQL Server […]

Connecting to SQL Server Database using a Hosted Web Application

I have created a .net web application using c# that inserts, updates, and deletes data from an SQL server database. I have tested it using my localhost and it works fine. Now I would like to publish this application on a hosted site. My question is, does the database need to be on the same […]

Entity Framework added 3 foreign keys for 1 relationship

I have a simple User Class public class User { public int ID { get; set; } [Required] public virtual ApplicationUser LoginID { get; set; } [Required] public string Name { get; set; } public string JobTitle { get; set; } [DefaultValue(UserRole.Standard)] public UserRole Role { get; set; } public virtual Company Company { get; […]

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