Tag: c#

The parameterized query … expects the parameter '@units', which was not supplied

I’m getting this exception: The parameterized query ‘(@Name nvarchar(8),@type nvarchar(8),@units nvarchar(4000),@rang’ expects the parameter ‘@units’, which was not supplied. My code for inserting is: public int insertType(string name, string type, string units = “N\\A”, string range = “N\\A”, string scale = “N\\A”, string description = “N\\A”, Guid guid = new Guid()) { using (SqlConnection connection […]

Should you make multiple insert calls or pass XML?

I have an account creation process and basically when the user signs up, I have to make entries in mutliple tables namely User, Profile, Addresses. There will be 1 entry in User table, 1 entry in Profile and 2-3 entries in Address table. So, at most there will be 5 entries. My question is should […]

SqlDependency Reliablity?

My current situation is that I have an application that needs to be notified when new data arrives in a database table. The data is coming from an external source (that I have no control over–this is this only integration option). When new data arrives, my application needs to take certain actions–basically query for the […]

Accessing System Databases/Tables using LINQ to SQL?

Right now I have an SSIS package that runs every morning and gives me a report on the number of packages that failed or succeeded from the day before. The information for these packages is contained partly within the sysjobs table (a system table) within the msdb database (a system database) in SQL Server 2005. […]

How to Specify Primary Key Name in EF-Code-First

I’m using Entity Framework Codefirst to create my Database. The default Primary key with the schema name dbo.pk_Jobs seems to upset access 2007 when I connect to it over ODBC. If I manually edit the name and remove the schema name and rename this Primary Key to pk_jobs, Access can now read the table. Can […]

C# How to get SQL Server installation path programatically?

How do I get the installation path for a given instance of SQL Server (default and name instances)

Upload CSV file to SQL server

What is the best way to upload a large csv data file into SQL server using C# ? The file contains about 30,000 rows and 25 columns.

Use of SqlParameter in SQL LIKE clause not working

I have the following code: const string Sql = @”select distinct [name] from tblCustomers left outer join tblCustomerInfo on tblCustomers.Id = tblCustomerInfo.CustomerId where (tblCustomer.Name LIKE ‘%@SEARCH%’ OR tblCustomerInfo.Info LIKE ‘%@SEARCH%’);”; using (var command = new SqlCommand(Sql, Connection)) { command.Parameters.AddWithValue(“@SEARCH”, searchString); … } This does not work, I tried this as well: const string Sql = […]

Display a ConnectionString dialog

I’m trying to create a program in C# that should be able to create, backup and restore a SQL Server database. For this, the user needs to be able to setup a connection string to the desired SQL Server (and database). I would like to use the same dialog as for example Visual Studio for […]

Is there a .NET equalent to SQL Servers newsequentialid()

We use Guid’s for primary key, which you know is clustered by default. When inserting a new row into a table it is inserted at a random page in the table (because Guid’s are random). This has a measurable performance impact because the DB will split data pages all the time (fragmentation). But the main […]

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