Tag: ado.net

Pass (1,2,3,4) as a SqlParameter

I am trying to pass this dynamically generated string (1,2,3,4) but I am getting the error: Conversion failed when converting the nvarchar value ‘1, 2, 3, 4’ to data type int How can I fix this error? public DataTable GetAll(int [] idArray) { DataTable dt = new DataTable(); var paramNames = Enumerable .Range(0, idArray.Length) .Select(index […]

SSIS Script Task- Connecting thu ADO.NET and populating DataTable

I need to connect to a SQL Server db thru a script task in order to populate a DataTable, I’m using ADO.Net provider/connection. However for the life of me I’m getting all sorts of errors. For example, when using the SqlAdapter I get an invalid object error, however the SqlCommand executes without errors in SSMS: […]

Stored Procedure is taking time in execution

I am facing a very strange issue with SQL Server that I have a stored procedure and I am executing the procedure from C# code. The procedure will return a datatable / dataset. My problem is that procedure is taking too much time in execution from C# code / ADO.NET code (around 2 minutes). But […]

SQL Server timestamp column not supported in Mono?

I am trying to run a .NET command line application in Linux using Mono. It accesses SQL Server 2005 Express database and, when querying some data it throws the following exception: System.NotSupportedException: Unknown Type : timestamp at Mono.Data.Tds.TdsMetaParameter.GetMetaType () [0x00000] at Mono.Data.Tds.Protocol.Tds70.WriteParameterInfo (Mono.Data.Tds.TdsMetaParameter param) [0x00000] at Mono.Data.Tds.Protocol.Tds70.ExecRPC (System.String rpcName, Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean wantResults) […]

ADO.NET: What API I can use to get message when SET NOCOUNT OFF

Many articles recommend adopting “SET NOCOUNT ON” to avoid receiving message like “1 Row(s) affected”. I’m curious what ADO.NET API I can use to get message when SET NOCOUNT OFF. Thanks.

Invalid Object Name: Beginner using the AdventureWords db from a class

I’m trying to learn some C#.net. I’m just trying to expose the AdventureWorks database included in my C# class via a web interface. Here’s the setup: I’ve got a DropDownList in on my ASPX page with an id of tableNameDropDown. It gets populated on Page_Load like this: protected void Page_Load(object sender, EventArgs e) { conn.Open(); […]

insert data to db in loop performance

I’m trying to write Windows app to get data from From Fox Pro DB, and inset it to Sql Server 2008 db. I wrote code, but it works very slow. rowsCount more than 1 million My code below: OleDbConnection cn = new OleDbConnection(foxProConnectionString); SqlConnection cSql = new SqlConnection(sqlServerConnectionString); cSql.Open(); OleDbCommand ocmd = new OleDbCommand(“Select * […]

How can I check if the connected SQL Server is on the local machine?

Is there any way of telling, using C#, if the Sql Server I’m connected to in Ado.Net is on the local machine rather than remote? I’m wanting to know whether I have access to the file system where SQL Server stores, for example it’s backup files. That would let me determine whether I would be […]

Creating SQL users and restricting their permissions

Greetings, My program creates a SQL database using ADO.NET APIs to connect to a SQL server and manipulate SQL connections/transactions. When the database is created, I’m connecting to the server using ‘sa’ credentials. This will be the only time I will connect to the database using ‘sa’ credentials. During this same initial connection, I need […]

SqlClient.SqlException .Number = 3617 .State = 68

We are receiving this exception from one of our sql select statements. I cannot find error 3617 in the sysmessages table. The .Class is 25. There is no message. We know we are getting it on Sql server 2005 servers. I do know that this is large select that joins several tables and uses the […]

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