Tag: asp.net

C# ASP.NET: create general method to call Stored Procedure with any number of parameters

In the project I’m working to in this period I have to work a lot with stored procedures in SQL Server, actually I use this method (using Dapper): public static foo_type call_stored_procedure(string stored_procedure_name, string ConnectionString, type_param_1 param1, type_param_2 param2) { using (var connection = new SqlConnection(ConnectionString)) { connection.Open(); var server_return = connection.Query<foo_type>(stored_procedure_name, new { param1 […]

commandargument for sql dataset buttonfield

I have a sql dataset table which has two buttonfields (upvote and downvote). I am trying to add a commandArgument to these two buttonfields which links up to the sql data value compName (see code below) but I keep getting the following error: “Error 6 Databinding expressions are only supported on objects that have a […]

Catching SQL Connection Error and retrying

I have a web application, it’s working fine and doesn’t really run into any issues. However, if the SQL Server is being restarted, or if it loses connection, then the application falls over with the standard error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found […]

How can I get my application database offline?

I’ve got an internal ASP.Net application which I would like to send to someone. The problem I have is that the app is using local SQL Server database. Is it possible to have a copy of the database to the file and just replace the access to the db for the file? If yes how?

Use SQL Server database in ASP.Net without server installation?

Is it possible to use a SQL Server database, i.e. a .mdf file, without having to install SQL Server (Express)?

How to reduce deadlocks on select statement

Can someone know how to fix this problem? When I trace the error. I saw a piece of code calling this query. SqlException : Transaction (Process ID 57) was deadlocked on lock SELECT A.[CallID] FROM dbo.[Calls] A WITH(NOLOCK) INNER JOIN [dbo].[Issues] B WITH(NOLOCK) ON A.[CallID] = B.[CallID] WHERE A.[AddedByUserID] = @UserID AND A.[EndTime] IS NULL […]

How can I use SQL Server bulk insert in asp.net?

I’m a beginner in asp.net and write a web application. I have 100 million records in my server in a .csv file, and I write this query in SQL Server to import all that data: BULK INSERT BpartyTEMP FROM ‘D:\bparty2.csv’ WITH( FIELDTERMINATOR = ‘,’, ROWTERMINATOR = ‘\n’, CODEPAGE = ‘1256’ ); But I want write […]

SQL Delete Query Foreign Key constraint

I am trying to Delete record with primary key as foreign key in two tables. Everytime I try to run the query it gives me this error: Query: DELETE FROM BusinessPlus_Post FROM BusinessPlus_Post INNER JOIN BusinessPlus_PostImage ON BusinessPlus_Post.Post_ID = BusinessPlus_PostImage.BusinessPlusPost_ID INNER JOIN BusinessPlus_PostTag ON BusinessPlus_Post.Post_ID = BusinessPlus_PostTag.BusinessPlusPost_ID WHERE (BusinessPlus_Post.Post_ID = 3) AND (BusinessPlus_PostImage.BusinessPlusPost_ID = 3) […]

Connecting to SQL Server Express database with c# asp.net

I was able to connect to a database on a server on my network with no problem. However, when I attempt to use SQL Server Express (local db), I keep getting the same error. I created a new solution with only a button and label as to eliminate any other potential issues. I have looked […]

Large number of database reads while calling procedure using Entity Framework 4

In my asp.net c# application I am calling a procedure using entity framework 4.0 my problem is that on live site I receive time out issue (it takes more than 1 min to complete execution) But same procedure when I call from management studio (sql server 2012) it takes hardly 6 sec (even after using […]

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