Tag: ado.net

How to use DataAdapter.Fill() asynchronously?

I have a DataAdapter that is filling 5 DataTables in a DataSet. SqlDataAdapter da = new SqlDataAdapter(“Select * from testTable”,con); da.Fill(ds, 0, numberOfRowsToPutInEachDataTable, “DT1”); da.Fill(ds, numberOfRowsToPutInEachDataTable , numberOfRowsToPutInEachDataTable , “DT2”); da.Fill(ds, numberOfRowsToPutInEachDataTable* 2, numberOfRowsToPutInEachDataTable, “DT3”); da.Fill(ds, numberOfRowsToPutInEachDataTable * 3, numberOfRowsToPutInEachDataTable, “DT4”); da.Fill(ds, numberOfRowsToPutInEachDataTable * 4, numberOfRowsToPutInEachDataTable, “DT5”); My goal is to get each da.Fill… to […]

Why wont DataGridView Update Database?

I have a DataGridView populated with a DataSet from my Database. I am trying to make changes in the DataGridView and apply those changes to the Database whenever I press ‘Enter’. Iv read alot of this same question, and researched the topic, but am still having trouble figuring out why I cannot apply changes made […]

ASP.NET MVC4 – ADO.NET – Saving a large number of files from ZipArchives to sql server

I have a set of incoming zip file(s) that can be upto 2GB in total and will contain thousands of files. (files include jpg, pdf, txt, doc, etc) Every file will be saved as a separate row in a SQL Server 2014 database table using a stored procedure that takes a Table valued parameter and […]

Syntax for UPDATE statement with parameters?

Here’s the working SQL Statement: DECLARE @LayOdds DEC = 1.5 DECLARE @Umarketiduselectionid VARCHAR(50) = ‘1.12677402748783’ UPDATE [dbo].[Fixtures] SET [Fixtures].[Percent] = [Fixtures].[BackOdds] / @LayOdds * 100 – 100 WHERE [Fixtures].[MarketSelectionId] = @Umarketiduselectionid Here’s my incorrect C# Statement: string sql = “Update Fixtures SET Percent = BackOdds / @LayOdds * 100 – 100 WHERE MarketSelectionId = @Umarketiduselectionid”; […]

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(); […]

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