Tag: ado.net

ExecuteNonQuery() Exception with date insertion

I have a stored procedure to insert record and returns the ID of record inserted. Here is my SQL implementation: ALTER PROCEDURE InsertViolation @FactoryName nvarchar(50) , @Type nvarchar(100), @Location nvarchar(30) , @Desc nvarchar(300), @Severity nvarchar(300), @DateObserved datetime, @ViolationNumber bigint output AS BEGIN SET NOCOUNT ON; INSERT INTO Violation (Violation_Factory_Name ,Violation_Type ,Violation_Location ,Violation_Desc ,Violation_Severity ,Violation_Date_Observed) VALUES […]

ADO.NET – Trouble Getting Output Parameter

My DBA created the following Stored Proc which he insists works fine when called in SQL Server: CREATE procedure [dbo].[GetParentID] @SSHIP_AppID as varchar(50), @ParentID as varchar(150) OUTPUT AS BEGIN SET NOCOUNT ON; SELECT @ParentID = a.iBuild_GUID FROM dbo.XRef_iBuild_SSHIP as a WHERE a.SSHIP_appId = @SSHIP_AppID AND a.SSHIP_appId <> ” END I have created the following ADO.NET […]

SQL Server Database Update using Multithreading

I have a requirement to update 20 tables in a SQL Server database in a C# application. For better performance, I am planning to use multiple threads for updating tables. Could anybody refer any example link which gives idea for this kind of operation? Also, as per my understanding, if I use multi threading, then […]

SQLException on ADO.Net SqlCommand.EndExecuteReader

I’m trying to call out to a stored procedure asynchronously with multiple calls on the one connection via ADO.Net SqlCommand. The calls are being triggered on a timer every half a second and for some of the time I am receiving the results back as expected and sometimes I am receiving the following error: System.Data.SqlClient.SqlException […]

Get size of SqlDataReader payload

I am trying to figure out the size of the payload that gets returned from SQL Server. The code I have is using ADO.NET: using (var command = new SqlCommand(“SELECT * FROM [dbo].[Products]”, connection)) { SqlDataReader reader = command.ExecuteReader(); // find # of bytes of payload returned However, I am unsure how to get the […]

Search-Filtering GridView control results in no records found

I’m trying to filter-search the data from a GridView control which is bound to a SQL data connection but i’m not having any success. Whenever I try to search for something, it results in no records found. Here is my main searching code: public void FilterGridView(string column, string terms) //SELECT * FROM [Table_1] WHERE [First […]

Extract machine name from connection string

This question already has an answer here: How to get server name through code if SQL Server (Standard Edition) is installed 3 answers

SQL Server – Getting Execution Plan XML By Proc Name

I am developing a .NET program to retrieve execution plans of all stored procedures in a given database. I am going to parse these XML’s at program side. SET SHOWPLAN_XML ON and execute the procedure gives the plan. However, the problem is that all the parameters of the procedure needs to be passed. Is there […]

Inserting multiple records from my Web site fails

I am querying a Web site for 5 yrs worth of data from 150 data points, which is about 40000 records each(total 6m records), and inserting the result into my database. This is part of a Web application. I am using VS 2010 and SQL server 2008 Express. I have two questions unrelated to each […]

Cannot open database error

I have the below query in my console appliaction SqlConnection myConnection = new SqlConnection(“user id=abc;” + “password=xyz;server=test;” + “Trusted_Connection=yes;” + “database=tested123; ” + “connection timeout=30”); myConnection.Open(); When I run the above application, it is working fine .But when publish this, it is throwing an error for the other users who are not having access to […]

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