Questions tagged [sqldataadapter]

Represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database.

The SqlDataAdapter, serves as a bridge between a DataSet and SQL Server for retrieving and saving data. The SqlDataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet, using the appropriate Transact-SQL statements against the data source.

438 questions
53
votes
4 answers

ReadOnlyException DataTable DataRow "Column X is read only."

I've got a short piece of code that originally created an SqlDataAdapter object over and over. Trying to streamline my calls a little bit, I replaced the SqlDataAdapter with an SqlCommand and moved the SqlConnection outside of the loop. Now,…
user153923
38
votes
4 answers

c# Using Parameters.AddWithValue in SqlDataAdapter

How can I use Parameters.AddWithValue with an SqlDataAdapter. Below searching codes. var da = new SqlDataAdapter("SELECT * FROM annotations WHERE annotation LIKE '%"+txtSearch.Text+"%'", _mssqlCon.connection); var dt = new…
user1372430
29
votes
5 answers

SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable?

I want to know which one has the better performance for returning a DataTable. Here for SqlDataReader I use DataTable.Load(dr) Using SqlDataReader: public static DataTable populateUsingDataReader(string myQuery) { DataTable dt = new…
Satinder singh
  • 10,100
  • 16
  • 60
  • 102
15
votes
2 answers

connected model and disconnected model in EF

I'm confused a lot about connected model and disconnected in entity framework . I was using traditional ADO.net (DataReader for connected model and DataAdapter for disconnected model) and all I know that I use connected model when I have many users…
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
11
votes
2 answers

Confused between SqlCommand & SqlDataAdapter

everyone I am a student and new to .NET and specially MVC3 development but for one of my project I’ve to work over it and so going through the learning phase Issue and confusion I am facing is regarding DB-Connectivity, whast I leanree d regarding…
Maven
  • 14,587
  • 42
  • 113
  • 174
10
votes
3 answers

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 …
Phil
  • 1,811
  • 9
  • 38
  • 60
8
votes
1 answer

Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding

When I run my code I get the following exception: An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll Additional information: Execution Timeout Expired. The timeout period elapsed prior to completion of…
wouter de jong
  • 547
  • 2
  • 7
  • 20
8
votes
1 answer

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…
CraigJSte
  • 912
  • 6
  • 17
  • 33
8
votes
1 answer

Should you reuse SqlConnection, SqlDataAdapter, and SqlCommand objects?

I'm working with a DAL object that is written in a layout similar to the following code. I simplified a lot of the code code just to show the setup. public class UserDatabase : IDisposable { private SqlDataAdapter UserDbAdapter; private…
Equixor
  • 259
  • 4
  • 13
7
votes
2 answers

SqlDataAdapter.Fill() vs DataTable.Load()

I come from this question here but I have a different case. I need my result in a DataTable and I have 2 potential methods: public static DataTable SelectDataTable(string query, string ConnectionString) { using (SqlConnection myConnection…
Impostor
  • 2,080
  • 22
  • 43
6
votes
2 answers

SqlDataAdapter.Fill is too slow even for one record

I have a table with primarykey in MS SQL 2005, which has a few hundred thousand records. When I query it in Management studio for a record, it brings very quickly but when i use code below to find it, it takes many seconds. It is must for me to use…
Adeem
  • 1,296
  • 1
  • 16
  • 30
6
votes
1 answer

Add parameter to dataAdapter.fill()

I am trying to add a parameter to a sqlDataAdapter. I have tried to use parameters.add() but the adapter is not a sqlCommand. Here is some of my code. Private Sub convertToCSV(ByVal SqlQuery As String) Dim Dt As New DataTable() Dim…
JDV590
  • 651
  • 3
  • 15
  • 33
6
votes
3 answers

Data Adapter Vs Sql Command

Which one would be better in executing an insert statement for ms-sql database: Sql DataAdapter or SQL Command Object? Which of them would be better, while inserting only one row and while inserting multiple rows? A simple example of code…
Jayesh
  • 1,511
  • 1
  • 16
  • 37
5
votes
2 answers

Using SqlDataAdapter to page a SqlDataReader source

This question seems to be common and I went through this answer already. Unfortunately, my page still isn't being paged. Here's what my code looks like in C#: SqlCommand command = new SqlCommand("(SELECT ......", Connection); SqlDataAdapter…
Kevin
  • 3,209
  • 9
  • 39
  • 53
5
votes
2 answers

SqlDataAdapter gives parameter name invalid error when setting batch size

I'm trying out the batch inserting/updating of SqlDataAdapter. When I set UpdateBatchSize = 1, it works, but setting it to 2 gives the exception "Specified parameter name 'Id' is not valid.". using (var sqlDataAdapter = new SqlDataAdapter { …
Kelly Selden
  • 1,238
  • 11
  • 21
1
2 3
29 30