Tag: asp.net

Procedure or function has too many arguments specified

I get an error Procedure or function “myStoreProcNameHere” has too many arguments specified. Below is my stored procedure and SqlDataSource. I’m using a GridView to edit data. Help? 🙁 Stored procedure: ALTER PROCEDURE UpdateTwoTables (@ID int, @UserID varchar(10), @Pass varchar(50), @Enabled int, @Permission int, @Rank int, @FName varchar(50), @LName varchar(50), @Phone varchar(50), @Email1 varchar(50), @Email2 […]

Convert date to ticks in SQL Server

Does anyone know how to convert a DATETIME COLUMN to TICKS in SQL Server?

ASP.NET Website Administration Tool: Unable to connect to SQL Server database

I am trying to get authentication and authorization working with my ASP MVC project. I’ve run the aspnet_regsql.exe tool without any problem and see the aspnetdb database on my server (using the Management Studio tool). my connection string in my web.config is: <connectionStrings> <add name=”ApplicationServices” connectionString=”data source=MYSERVERNAME;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true” providerName=”System.Data.SqlClient” /> </connectionStrings> The error I […]

Passing comma-separated value from .NET to stored procedure using the value in “IN” SQL function

I have an SQL query similar to the following: create procedure test ( @param1 nvarchar(max) ) as begin select * from table where column1 in (@param1) end Now I need to pass the value of @param1 from my .net application in such a way that the above query works. Can some one please advise me […]

You do not have permission to use the bulk load statement

Hi I’m getting the error You do not have permission to use the bulk load statement. when I try to execute a stored procedure. I’ve seen some websites mentioning about the bulkadmin role, but I don’t see it. I’m using SQL Server 2008. Any ideas?

Reading binary from table column into byte array

I’m using PBKDF2 in my application to store users passwords. In my Users table, I have a Salt and Password column which is determined like this: // Hash the users password using PBKDF2 var DeriveBytes = new Rfc2898DeriveBytes(_Password, 20); byte[] _Salt = DeriveBytes.Salt; byte[] _Key = DeriveBytes.GetBytes(20); // _Key is put into the Password column […]

C# Alter Table and Add a column programmatically ASP.Net & SQL Server

I have been trying to add a column programmatically in ASP.NET to modify the tables in SQL Server. Please see the following code: string suppliernotxt = supplieridlist[1].ToString(); //SqlCommand cmd2 = new SqlCommand(“ALTER TABLE [ProductNormalDB] ADD suppliernotxt nvarchar(20) NULL”, con); SqlCommand cmd2 = new SqlCommand(“ALTER TABLE ProductNormalDB ADD @supplierlist nvarchar(20) NULL”, con); cmd2.Parameters.AddWithValue(“@supplierlist”, suppliernotxt); //cmd2.Parameters.AddWithValue(“@supplierlist”, suppliernotxt.ToString()); […]

LINQ to SQL execution time is 50x longer than SSMS SQL

I have an asp.net app that uses Linq to SQL. One query from the app was timing out (over 30 seconds to execute). I increased the CommandTimeout of the DataContext, and it did complete in 45 seconds. I copied the Linq to SQL generated SQL from SQL Profiler to SSMS and executed it using the […]

Unit test insert/update/delete

I have googled this a little and didn’t really find the answer I needed. I am working on a webpage in C# with SQL Server and LINQ for a customer. I want the users to be able to send messages to each other. So what I do is that I unit test this with data […]

Passing an object collection as a parameter into SQL Server stored procedure

I have a general question on whether something can be done – and whether it will be the most efficient way of doing it ! To summarise: can I pass an object collection as a parameter to a stored procedure? Let’s say that I have a SQL Server table called Users [UserID, Forename, Surname] and […]

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