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

data adapter.select command.connection

I am using below code to get data from database.But immediately,when breakpoint goes to any line after var k,exception is raised. DataSet ds = new DataSet(); try { using (SqlConnection con = new…
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
3
votes
2 answers

CommandTimeout not working when using SqlDataAdapter to fill a DataTable

I am setting CommandTimeout to 1 second and no TimeoutException is being thrown as expected. The query I am running takes about 7-8 seconds. The timeout does work however when I use ExecuteReader to execute a query rather than trying to fill a…
Ersl
  • 31
  • 2
3
votes
2 answers

.Net SqlDataAdapter and triggers in SQL Server

I am using a trigger in SQL Server that works as required when executing a query in the query window in SQL Server Management Studio. The objective of the trigger is to take the latest value from one table (where an id corresponds to the inserted…
user2502832
  • 65
  • 1
  • 4
3
votes
4 answers

How to limit the number of rows in dataset

Code to refer [WebMethod] public static string GetData() { string query = "SELECT * FROM tblCountry"; SqlCommand cmd = new SqlCommand(query); return GetData(cmd).GetXml(); } private static DataSet GetData(SqlCommand cmd) { …
Angelina
  • 85
  • 1
  • 2
  • 7
3
votes
3 answers

How to Use an Update Statement in SQLDataAdapter

I am trying to run an update statement after i built my sqldataadapter. I have column called INIT_PHASE in my table and if the INIT_PHASE is null or there is no data then i would like to set it to 1. I have tried but i can't seem to get it right…
moe
  • 5,149
  • 38
  • 130
  • 197
3
votes
1 answer

Running multiple stored procedures with one SqlDataAdapter

My question: is there any way to run multiple stored procedures with one SqlDataAdapter like this adapter = new SqlDataAdapter("ProcforselectUserTableWhere ; ProcforselectuserTypeAuthorizationWhere", con); adapter.SelectCommand.CommandType =…
Saveen
  • 702
  • 2
  • 14
  • 34
3
votes
2 answers

Invalid enumeration value and SqlDataAdapter.Update(DataTable)

I'm getting the ArgumentOutOfRangeException "The StatementType enumeration value, 4, is invalid" when trying to update a data table through SqlDataAdapter.Update(DataTable). According to…
Brian
  • 432
  • 1
  • 5
  • 12
3
votes
4 answers

collection was modified enumeration operation may not execute

Okay, so I want to open a new form if it isn't already open. So I check for the form based on the Title or text of the form. Now, so far it works, as in the form opens and if it is already open, it just brings it to the front. But my problem being,…
Dr Archer
  • 348
  • 1
  • 3
  • 14
3
votes
1 answer

SqlCommandBuilder Inner Join Update

I have SQL tables as Lessons and Classes. Lessons table has primary key LessonID and Classes table has primary key ClassID. Also ClassID column is foreign key at Lessons table. I import data with SqlDataAdapter to DataSet in C# using query: select *…
Sertan Pekel
  • 593
  • 2
  • 5
  • 23
3
votes
7 answers

Returning dataset values giving an error

I have defined the following function which would return 3 columns from table. public DataSet GetFunc() { int iRet = 0; DataSet ds = new DataSet(); SqlConnection sqlConnection = new SqlConnection(); try …
Esha
  • 391
  • 1
  • 9
  • 37
3
votes
2 answers

Populating Dataset from DataAdapter error

I'm trying to do what the title said but I get this error at runtime: Incorrect syntax near the keyword 'Top'. string connString = @"server =.\sqlexpress; Database=BestScores.mdf; trusted_connection=TRUE; AttachDbFileName= D:\Programing\Projects…
Adrian Tanase
  • 71
  • 1
  • 5
3
votes
3 answers

DataTable from TextFile?

I have taken over an application written by another developer, which reads data from a database, and exports it. The developer used DataTables and DataAdaptors. So, _dataAdapter = new SqlDataAdapter("Select * From C....", myConnection); and…
Craig
  • 18,074
  • 38
  • 147
  • 248
3
votes
1 answer

SqlDataAdapter.DeleteCommand() works with AddWithValue() but not with Add() - Why?

Microsoft's own documentation provides an example of deleting a record as follows: // Create the DeleteCommand. command = new SqlCommand( "DELETE FROM Customers WHERE CustomerID = @CustomerID", connection); // Add the parameters for the…
Not So Sharp
  • 1,149
  • 2
  • 10
  • 20
2
votes
1 answer

DataGridView, DataTable, SqlDataAdapter and SqlCommandBuilder - disable deletes

I have a WinForm that has a DataGridView table. It is bound to a DataTable in conjunction with a SqlDataAdapter and SqlCommandBuilder. What is the best way (easy and easy to manage) of disabling Deletes but allowing Selects, Updates, Inserts? Is…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
2
votes
1 answer

SqlDataAdapter.Update silently fails

In my application, I have a control that displays the contents of a database table to the user. This control holds the data to display in a System.Data.DataSet object. The user is able to modify the data displayed in the control, and this data is…
CadentOrange
  • 3,263
  • 1
  • 34
  • 52
1 2
3
29 30