sqldataadapter

How to correctly filter a datatable (datatable.select)

Dim dt As New DataTable Dim da As New SqlDataAdapter(s, c) c.Open() If Not IsNothing(da) Then da.Fill(dt) dt.Select("GroupingID = 0") End If GridView1.DataSource = dt GridView1.DataBind() c.Close() When I call da.fill I am inserting all records from my query. I w...

TransactionScope not rolling back with SqlDataAdapter.Update

I'm using SqlDataAdapter.Update with DataTables to update two SQL tables in a single transaction. If either insert fails I want to roll back all data. This is my code: using (var conn = new SqlConnection(_connectionString)) { conn.Open(); using (var scope = new TransactionScope()) { // Insert first table usi...

How to check for errors when running DataAdapter/DataSet SQL query?

This is how I update a table using DataAdapter and DataSet in VB using SQL Server: sqlStmt = String.Format("INSERT INTO my_table (name, lastname) VALUES ('John', 'Doe')") ds = New DataSet da = New SqlDataAdapter(sqlStmt, My.Settings.ConnectionString) da.Fill(ds) I know that the Fill method does not make sense in case of an INSERT stat...

C# SqlDataAdapter.Update()

Hi Anyone, Im going crazy with this. I did the ff: Create a datatable. Fill it from a SQL db thru SqlDataAdapter. Edit the datatable thru datagridview. Call the sqldataadapter.update but the changes are not persisted to the db. A closer look at the datatable after editing, the row states were not updated even if i actually edited th...

Calling a stored procedure with null parameters and SqlDataAdapter

Hello, I have a stored procedure which I cann from my C# code. I am passing some parameters which I put in a HashTable first. It looks like that: paramname1 value1 paramname2 value2 paramname3 value3 Any of the values can be null. So now I am going through that hash and add the params to the adapter: foreach (DictionaryEntry...

SQL Server 2008 - Stored Procedure Gets Stuck When Called From WPF Service Using a SqlDataAdapter

This has me pulling my hair out. We have a workflow, hosted as a WCF service, which makes a call to another WCF service which then calls a stored procedure. Store procedure calls a merge, then iterates through a cursor that calls another sproc. The cursor count is the same as the source count in the merge. If the source count is high...

C# SqlDataAdapter.Fill giving error about data conversion when passed datatable parameter

I'm trying to fill a datatable using a SqlDataAdapter in C#. I'm not very familiar with the objects, and am basically working off a template of someone else's code to try to figure out how it works. Here's the basic form. SqlCommand command = new SqlCommand(@"SELECT * FROM tblEmployees WHERE Name = " + firstSSN,connection); ...

SqlDataAdapter issues

Hi, There are several queries to be performed which return the DataTable object. In order to speed up the development I created a private method which should return the dataset by taking the query string as an argument. the method is the following: private DataTable getDataTable(string query) { DataTable dt = new DataTable...

64-bit OutOfMemoryException with SqlDataAdapter

The environment is: 64-bit Windows ~50GB RAM .NET 3.5 SP1 SQL 2008 The code is (essentially, from memory): System.Data.DataTable table = new System.Data.DataTable(); SqlCommand command = new SqlCommand("SELECT XmlColumn FROM Table WHERE ID = UniqueID", Connection); SqlDataAdapter adapter = new SqlDataAdapter(command); adapter.Fil...

SqlDataAdapter Output Variable Question C#

I do not clearly understand how to format the SqlDataAdapter for output variables when working with C# Error Message: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Code Example (Stored Procedure works fine) private DataTable updateOrdEodHold(DataTable tb, out string mn...