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
5
votes
2 answers

SqlDataAdapter with using keyword

Is this the following code healthy? Or I don't need to use the using keyword as the SqlDataAdapter will handle closing the connection? public static DataSet Fetch(string sp, SqlParameter [] prm) { using (SqlConnection con = new…
Akkad
  • 609
  • 1
  • 7
  • 14
5
votes
1 answer

How SqlDataAdapter works internally?

I wonder how SqlDataAdapter works internally, especially when using UpdateCommand for updating a huge DataTable (since it's usually a lot faster that just sending sql statements from a loop). Here is some idea I have in mind : It creates a…
tigrou
  • 4,236
  • 5
  • 33
  • 59
4
votes
1 answer

Use SqlDataAdapter and DataTable to get and update on SQL server with PowerShell

I am trying to use PowerShell to get a System.Data.DataTable from an SQL server, edit the data, and update it back to the SQL server but I cannot get it to work. The below code runs/executes but the data is not changed. $sqlConnection = new-object…
IMTheNachoMan
  • 5,343
  • 5
  • 40
  • 89
4
votes
1 answer

Updating database view using SqlDataAdapter

In my application, I want to bind GridControl to DataTable that contains data from multiple database tables (referenced with foreign keys). I had a problem with updating data, since I was using SqlDataAdapter on a command that referenced multiple…
Marcin Bator
  • 341
  • 1
  • 8
  • 23
4
votes
1 answer

Best performance in reading million records of data

I have a database with a large number of data (millions of rows), and also is updating during the day with large number of data, I have a back up of this database for reporting, so getting report of data does not affect on the performance of main…
Paridokht
  • 1,374
  • 6
  • 20
  • 45
4
votes
3 answers

How bad is opening and closing a SQL connection for several times? What is the exact effect?

For example, I need to fill lots of DataTables with SQLDataAdapter's Fill()…
Eren
  • 284
  • 2
  • 10
4
votes
3 answers

Strange behaviour of DataTable with DataGridView

Please explain me what is happening. I have created a WinForms .NET application which has DataGridView on a form and should update database when DataGridView inline editing is used. Form has SqlDataAdapter _da with four SqlCommands bound to it.…
Paul
  • 25,812
  • 38
  • 124
  • 247
4
votes
5 answers

Is there a more elegant form for assigning NULL to InsertCommand's NVarChar?

This code works for me very well: if (someStr == null) da.InsertCommand.Parameters.Add("@SOMESTR", SqlDbType.NVarChar).Value = DBNull.Value; else da.InsertCommand.Parameters.Add("@SOMESTR", SqlDbType.NVarChar).Value = someStr; But my intuition…
scatmoi
  • 1,958
  • 4
  • 18
  • 32
4
votes
3 answers

How does SqlCommandBuilder do its stuff and how can I stop ReSharper's suggestion to delete it?

I don't understand how SqlCommandBuilder does its thing. I have the following code: public void TestCommandBuilder() { var pubsDataSet = new DataSet("Pubs"); var pubs = ConfigurationManager.ConnectionStrings["PubsConnectionString"]; var…
comecme
  • 6,086
  • 10
  • 39
  • 67
4
votes
1 answer

How to discover that a DataColumn's underlying datatype is xml

I have a SQL Server data table that has an xml column. I run a select query using DataTable (Fill method of the SqlDataAdapter class). After execution, the type of the column is string. I am wondering how I could determine the actual SQL Server…
3
votes
2 answers

Do I have to worry about inserts/updates/deletes/injection attacks when I use the following SqlDataAdapter?

Do I need to do anything in order to prevent inserts/updates/deletes/injection attacks when I'm using the following code? public static DataSet getReportDataSet(string sqlSelectStatement) { SqlDataAdapter da = new…
Chronicide
  • 1,112
  • 1
  • 9
  • 32
3
votes
3 answers

Update or delete current row of database results

I'm trying to port some old VB6 code to C# and .NET. There are a number of places where the old code uses a RecordSet to execute a SQL query and then loop through the results. No problem so far, but inside the loop the code makes changes to the…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
3
votes
0 answers

Set dynamic column names when using Adapter.Fill , filling a DataTable with SQL Server conn

I'm filling a DataTable with SQL Server query results like so: System.Data.DataTable dataTableSQL = new System.Data.DataTable(); // write the sqlCode to dataTableSQL via adapter using (SqlConnection conn = new SqlConnection(@"Data…
Jar
  • 1,766
  • 1
  • 21
  • 27
3
votes
3 answers

DataAdapter Fill Async Exception

I have a set of async methods I wrote to handle a large amount of database pulls and compiles in a speedy manner. For the most part these work fantastic and have really worked wonders for my software. However, recently I have run into a small…
ARidder101
  • 315
  • 2
  • 6
  • 16
3
votes
0 answers

SQLDataAdapter.Fill() throwing Arithmetic overflow error converting expression to data type datetime

I have a custom method that handles calls to SQL which takes in a script and a list of SqlParamaters, executes the SQL and then fills a DataSet with any results via SqlDataAdapter. This has been in use for over 3 years on various projects without…
BrianKE
  • 4,035
  • 13
  • 65
  • 115
1
2
3
29 30