Tag: ado.net

What does a positive value for command.Parameters.IsDirty indicate?

I am trying to get some value in output parameters using SqlCommand Parameters. The stored procedure runs fine, giving proper records. I verified it executing procedure on Sql Server as well to be sure I am doing it right. Still, I’m not able to get output on server-side, it always comes nothing! While debugging, I […]

SQL SELECT statement (in vb.net) returning empty and/or weird rows

I am using VS Express 2012, SQL Server 2012. I have one table (computers) and two rows with 10 columns (HaHu_ID, Serial_Number, Brand, Model, OS, Processor, HDD, Memory, ST, Speed). I’ve been on this site reading as many posts as I can trying to create a vb.net interface to a SQL Server. I succeed at […]

How to save database after SQL query ADO.NET?

I have the connection to database public SqlConnection CreateConnection() { var con = new SqlConnection(s_connection); con.Open(); return con; } I have an INSERT query after this connection: SqlCommand myCommand = CreateConnection().CreateCommand(); myCommand.CommandText = “INSERT INTO Departments(Name, Phone) VALUES (@Name, @Phone);”; myCommand.Parameters.Add(“@Name”, SqlDbType.NVarChar, 20); myCommand.Parameters[“@Name”].Value = d.Name; myCommand.Parameters.Add(“@Phone”, SqlDbType.NVarChar, 20); myCommand.Parameters[“@Phone”].Value = d.Phone; myCommand.ExecuteNonQuery(); I want […]

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

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