Click here to Skip to main content
15,891,529 members
Everything / DataAdapter

DataAdapter

DataAdapter

Great Reads

by Antonino Porcino
How to use T-SQL function SCOPE_IDENTITY() to retrieve inserted rows identity values with CommandBuilders and DataAdapters
by dibley1973
The stored procedure framework now supports dynamic fields within multiple recordsets
by Mark Pelf
We explain how to debug and get more information on the generic Exception “Failed to enable constraints.
by Thakkar Amit
Code for converting the EntityCollection of a DataTable.

Latest Articles

by Mark Pelf
We explain how to debug and get more information on the generic Exception “Failed to enable constraints.
by paul1167
Enumerate System Features
by dibley1973
The stored procedure framework now supports dynamic fields within multiple recordsets
by Sander Rossel
Need some flexible in-memory data cache? DataSets might be what you're looking for...

All Articles

Sort by Score

DataAdapter 

23 Nov 2011 by Antonino Porcino
How to use T-SQL function SCOPE_IDENTITY() to retrieve inserted rows identity values with CommandBuilders and DataAdapters
1 Aug 2016 by dibley1973
The stored procedure framework now supports dynamic fields within multiple recordsets
13 May 2012 by Wendelius
Yes, you can use the stored procedure to handle the insertions to two different tables and call it using data adapter. For example, see: Modifying Data with Stored Procedures (ADO.NET)[^].
6 Jun 2012 by Stephen Hewison
Here you go:SELECT TOP 3 NewsId, NewsTitle, NewsDate FROM NEWS ORDER BY NewsDate DESCThe following orders the results so the newest are at the top:ORDER BY NewsDate DESCThe following instructs the SELECT to get just the first 3 rows:SELECT TOP 3
5 Nov 2013 by Amitava Bag (Kolkata)
//Alter "btn_FetchName_Click" Event//Alter LinetextBox_EmpName.DataBindings.Add(new Binding("Text", dataSet1.Tables[0], "EmpName", false, DataSourceUpdateMode.OnPropertyChanged));//New LinedataSet1.Tables[0].RowChanged += Form1_RowChanged;//Add New Eventvoid...
27 May 2014 by Member 10192936
Instead of lineds.Tables["employee"].Rows.Remove(row);just userow.Delete();The logic behind is that DataTable is just an off-line in-memory object representing data from your real DB table. You filled real DB employee table into your off-line DataSet ds object by callingda.Fill(ds,...
15 Jul 2022 by Mark Pelf
We explain how to debug and get more information on the generic Exception “Failed to enable constraints.”
6 Jun 2012 by Maciej Los
You can use a simple trick to get last 3 records in ascending order.SELECT *FROM (SELECT TOP 3 NewsId, NewsTitle, NewsDate FROM NEWS ORDER BY NewsDate DESC) AS DTORDER BY DT.NewsDate
29 Jul 2012 by om3n
Dear All,sorry for my english, I'm newbie in .Net programming I am using vb. net 2010 framework 4. I want to make the autocomplete textbox but get error message "AccessViolationException". provisions:2 pieces that use autocomplete textbox, textbox each data retrieved from a database...
29 Jul 2012 by Trak4Net
There are issues with changing the AutoCompleteSource on the fly. I am assuming your secondary code is happening as the user is typing i.e. TextChanged event.I have heard that setting the AutoCompleteSource to AutoCompleteSource.None prior to re-assigning the new source should solve the...
14 Jan 2013 by Sandeep Mewara
Looks like this is the cuplprit:Val(HowStill)It looks that HowStill is a textbox control. You might need to do:Val(HowStill.Text)
18 Dec 2013 by Maciej Los
Why to close connection, if a few lines down, connection is opened?If oledbcon.State = ConnectionState.Open Then oledbcon.Close()End If'here!oledbcon.Open()Please refer this: OleDbCommand Class[^] and have a look at code sample at the bottom of page.
8 Aug 2016 by Maciej Los
There's no inbuilt method to achieve that, but you can write custom "helper class":void Main(){ Dictionary Messagetype = new Dictionary(); Messagetype.Add("a", 1); Messagetype.Add("b", 1); Messagetype.Add("c", 2); Messagetype.Add("d",...
7 Mar 2018 by OriginalGriff
here may not be one. It could be held in a configuration file - the best way - and read on demand when the connection needs to be established (or read into a local variable which only exists while a method is running) It could be in a const value - and the compiler may optimise that to a in-line...
7 Dec 2021 by Afzaal Ahmad Zeeshan
Quote: create relationships between entities in a project that is being written from scratch, or specify what relationships to have between them? That's the best part about an ORM. You don't need to think about it yourself (apart from some index,...
13 May 2012 by vikas.pawar143
Hi, I am having two tables t1,t2. I want to insert into these two tables using a stored procedure and sqldataadapter. Is it possible to insert using single dataadapter and also batch update (da.update) using same dataadapter?. If it is possible please tell me how to do that?Thanks in...
6 Jun 2012 by Boaz Yaari
Hello,I'v build an apllication (as a part of my Uni homework) basicly it's a social network application, i'v completed all the UI and basicly all the client-side stuff.now i need to handle the server side and the database side.I have 2 questions:1) I want to have an web-based...
6 Jun 2012 by sadegh_rusta
hia have this tableMy table name is NEWSand this fields: NewsId ,NewsTitle,NewsDatea want get a queryby selecta want select 3 record of this table this 3 record is 3 last news by datei want get 3 record of end of table (3 record of end time,not of end table)please give me a query
6 Jun 2012 by John Orendt
Ok, I recommend windows operating system, Use C# with Visual Studio and SQL Server. For web server use IIS.This web chat uses AJAXand the above technology. This app does not store the messages across server reboots, it does not use a database. However it would not be hard to add that...
5 Nov 2012 by Dave Kreskowiak
A little Google goes a long way. Read me[^]
5 Nov 2012 by njammy
There really isn't a risk-free way of doing what your thinking/wanting, with just one command.To help you learn a little more about Datasets and how they can be used more efficiently, I present this possible solution.I would create a DataSet object in the project e.g. 'CustomDataSet'....
14 Jan 2013 by kosay85
HelloI make function to save data from datagridveiw to Access data BasePrivate Function SD() Dim I As Integer For I = 0 To Me.DataGridView1.Rows.Count - 1 Me.VendorLongBillTableAdapter1.Insert(Me.DataGridView1.Item(0, I).Value, Me.DataGridView1.Item(1, I).Value,...
17 Jan 2013 by rtz87
ivé been trying to delete a row from a table using dataset.tables.rows.remove(); specifying the row to be deleted in the remove function.what i did is exactly like this.SqlConnection con = new SqlConnection();con.ConnectionString = "initial catalog=employee;data source=192.168.1.2;user...
17 Jan 2013 by Tejas Vaishnav
As Danish suggest you can use DeleteCommand of SQLDataAdapterreview this link it might helps you...DeleteCommand[^]
26 Feb 2013 by Thakkar Amit
Code for converting the EntityCollection of a DataTable.
13 May 2013 by Am Gayathri
In my code am getting following error.ORA-06550: line 1, column 7:PLS-00306: wrong number or types of arguments in call to 'SAVE_DATA'ORA-06550: line 1, column 7:PL/SQL: Statement ignoredWhat will be the reason for this?code am using is, List listparamters =...
13 May 2013 by V.
If you type "ORA-06550" in google (or any other ORA error) you'll get the explanation. In this case, not much of help as it seems to be a generic error. My guess is that it might be because you add prm3 twice (not sure though): //btw is "paramters" a typ-o ? ...
13 May 2013 by Am Gayathri
The problem is with objDataAccessUtilities.ExecuteDataReader(command); instead of this we have to useobjDataAccessUtilities.ExecuteNonQuery(command);
14 Oct 2013 by v03051435
hi guys, i have a oracle issue : i use asp.net + oracle in my web app. in my oracle database, i have a view which contains the definition of ...name : view1 for examplewhere pro.FIN> to_date('01/11/12') and pro.FIN
4 Nov 2013 by DoingWork
Dear All,Problem Case: When adapter.Update(dataSet) is called then Data is not updated in DataBase.Here is my some piece of code. Complete code can be shared if demanded.//Declared at Class levelSqlConnection conn = null;SqlDataAdapter adptr = null;DataSet dataSet = new...
5 Nov 2013 by Amitava Bag (Kolkata)
Please bind EmpID in textBox_EmpId with the specific datatable within dataset and don't alter the value of this textbox. Let me know whether the problem persist?
18 Dec 2013 by davy.lambrechts
Hi guysI am developing a project using SQL server 2008 Express.My project is a newer version of an existing program we developed earlier using Microsoft Access as a database.What I want to do now is write a data conversion program so I can put the old data (Access) in the new datatabse...
18 Dec 2013 by OriginalGriff
130,000 rows is a lot to load in one go: I assume that you aren't trying to present this to the user directly!There are a couple of things you can do to speed it up, but with that number of rows they probably aren't going to have a major effect - but they are simple. Start by looking at your...
18 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Suggestions1. Who is going to see 13K records in a Page? So, limit your query to to return a small number of records.2. Always mention the column names in the select query. Selecting by * would return all columns, but all of them might not be required.3. As soon as the data are...
18 Dec 2013 by thatraja
Use approach like SqlBulkCopy[^]. And here a comparisonHigh performance bulk loading to SQL Server using SqlBulkCopy[^]
21 Dec 2013 by farhad Najib
HiYou can do these.Add a dataset to your project and then inser tor tables from Server Expolrer to it.You will have a dataadapter for each.then you can use them on your forms.Yours Farhad.
21 Feb 2014 by Member 10609511
Hi everyone,Basically I want to display data from two tables in my database within Visual studio 2010 into one data gridview. Just a brief background to my project - it is a website where users can upload content(Images and video). I have three tables - one table 'Incident' stores the...
21 Feb 2014 by Sandip.Nascar
You have several options here - 1. If you have links between the tables, use a query with join and make a one datatable to view it in one grid view2. If there are no relations at all between tables, I don't see any reason to use one grid view to show all the 3 tables. Create a link at the...
21 Feb 2014 by Peter Leow
I figured that you want to display username (available in user_acc table) and business name (available in business table) along side related data from incident table in one gridview. then you got to join the 3 tables like this, assuming that you have a user_id field and business_id field in the...
10 Mar 2014 by Qadeer Ahmed Khan
Hi, In the code below da.Fill(ds) takes around 500ms for the first and drops to 50ms for the second if I call the method without restarting the application. I tried DataReader same thing happens with it. On the other hand I used LINQ to SQL (On MS SQL Server) which returned the records in around...
10 Mar 2014 by Krunal Rohit
This could be anything. IDE bug, OS problem i.e Virtual Machine or settings of SSMS.See this : http://stackoverflow.com/questions/7992560/sqldataadapter-fill-suddenly-taking-a-long-time[^]http://stackoverflow.com/questions/250713/sqldataadapter-fill-method-slow[^]-KR
12 May 2014 by V.
What I usually do is set each object of the dataset into a class and make a Dictionary.eg. You select a bunch of persons from the person table. You create a Person class and each row is a new instance added to a Dictionary that has the tables primary key value as Dictionary key and the...
4 Sep 2014 by Pheonyx
I'm speculating here, but I thought that if you wanted to select information from multiple tables you need to join them.So were you have done this:from tab_inte i, tab_usty u You should be doing something like:from tab_inte i join tab_usty u on u.inteId = i.id (without knowing your...
3 Mar 2015 by User 10734264
when i call the function public DataTable GetAllBySurSurveyId(Int64 surSurveyId) { DataTable dtSurSurveyTeam = null; try { dtSurSurveyTeam = Adapter.sp_4_15_GetAllBySurSurveyId(surSurveyId); } catch...
4 Mar 2015 by Member 10971356
As the error message says, the types of constraints that you might violate are non-null, unique, or foreign-key constraints. Unless you add them yourself, they can only be created when DataTable and DataSet schema is generated automatically, by the Data Source or the like.This problem is...
11 Nov 2015 by jharding08
Looking for an easy example of how to bind data from a multi-join table dataset (main table with 3-4 foreign keys to lookup data) to a datagrid as well as textboxes and comboboxes.I'd like to be able to select from all available values in the combobox and then add/edit to the main form from...
22 Dec 2015 by Member 11858080
I have tried to Import Data From Database and while loading i need to show it in a progress bar so i added progress bar and backgroundWorker but I get an Error "Object reference no set to an instance of an object" I dont kno why. I have added My code here:Private Sub...
22 Dec 2015 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null -...
27 Jan 2016 by daneshmand1354
hello i fill my dataset(DataAdapter method) with query likeselect customerid,Customername,job from customers(query from microsoft sql server Database)how do i get field value like Customername for CurrentRowdirectly from dataset without using DataRow Class...
27 Jan 2016 by Michael_Davies
You can index directly to the elements of the dataset. The dataset contains a table and the table contains rows.dataset.Tables.Item(0).Rows.Item(rowindex).Item("name of column")Using a DataRow makes it simpler is all so why not.
8 Mar 2016 by Member 12378039
I'm trying to make my program go into the table in my database, called "tblEventsSigned" and then write data to a new row. However when the program gets to my Do Until loop to find an empty row is simply says there is no row at position 0 and I can't seem to fix it. Please help!SQL =...
2 Apr 2016 by KittoKy
I haven't used any Console.WriteLine to display the text i.e.: "Input string was not in a correct format" :( . I am trying to get data from database and save it in a double 2D array. One row in each array entry. This is my code : using System;using System.Collections.Generic;using...
2 Apr 2016 by CHill60
KittoKy wrote:but all are talking about exceptions and errors which are not solving my issueYour code is throwing an exception (error) and that text is the message associated with it. It is appearing as "output" from your program because it is a Console program.You have been told how to find...
29 May 2016 by George Jonsson
Not sure which code block you want to keep, so I used the uncommented code.1. You should always use the using statement, as it will close the connection automatically or use try-catch-finally2. You forgot to assign the CommandText property3. You have an integer type in your parameter...
23 Jun 2016 by emilius94
I have the following function under my update button to save changes in my datagridview back into SQL Server. The problem here is my table is over 40 000 records and it takes forever to fill to dataset every time the button is pressed. try { SqlConnection con = new...
23 Jun 2016 by emilius94
Fixed it by prompting to filter the data first before loading the records rather than applying the filter afterwards.
6 Jun 2019 by Kunal Ved
I am mantaining an application which is in old 3 tier arch.Have a common method created that executes the store proc and returns dataset and binds the gridviewpublic DataSet Execute_StoreProc_DataSet(string psStoreProcName) { DataSet dsResult= new DataSet(); UtilParams...
26 Jun 2016 by OriginalGriff
Start by looking at the SP. What it does, how it does it.Execute it via SSMS and see how long it takes, and what it returns - you need to establish where exactly the bottleneck is before you can start changing things to improve performance.If the SP take 5 minutes to run, then you are...
23 Jul 2016 by Member 12649673
Hello everyone!I try to fill a dataset in order to have datas in a gridview.The following code works for a WindowsApplication but not for a website.Can you tell me where i am wrong or what is missing?Thank you!Imports System.DataImports System.Data.OleDbPartial Class...
23 Jul 2016 by Karthik_Mahalingam
call DataBind after assigning the datasource GridViewCustomer.DataSource = ds.Tables("C") GridViewCustomer.DataBind()
8 Aug 2016 by ShaHam11
Hi I have list of data collected from traversing the notepad file and storing it in a dictionary and finally i print the output in console. Now i need to take this data into the datatable and then print it. Can anyone suggest me how to do this or achieve?My code static void...
12 Mar 2017 by Onur ERYILMAZ
I bound my datatable to datagridview, every column shows the correct data. But on my Image Column in datagridview does not show the image, instead it shows System.Drawing.Bitmap string.What am I missing?Thanks in advance...What I have tried:My codes are;
28 Aug 2017 by theskiguy
I am trying to update a database from a bound datagridview but I am not having very good luck. I want to first display the data in the datagridview then after making changes to the datagridview, I want to hit an update button to update the database. I have created the code that binds the...
28 Aug 2017 by theskiguy
I figured it out myself. I was mistakenly disposing my database connection in my finally clause after retrieving the data so I removed that code. I guess that is the reason I was getting the connection string error. I then modified my update button code slightly on now if works fine. ...
20 Oct 2017 by Member 13475705
private void combopop() { using (connection = new SqlConnection(connectionString)) using (SqlDataAdapter adapter = new SqlDataAdapter("Select * FROM BiludstyrTABEL", connection)) { DataTable dt3 = new DataTable(); ...
20 Jan 2018 by Member 13624040
I have a ComboBoxColumn in my datagridview. This is populated from database with a list of items. I need another column with price from my items table on the database. When a user selects an item from the Items Combobox, I need the price to be displayed on the column next to it. What I have...
20 Jan 2018 by Karthik_Mahalingam
try this using System; using System.Data; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) ...
24 Jan 2018 by Member 9983063
Hello Guys, I was working on c# win form but I leave this project for some time now today when I open my project and I add a form to my application and when I run so am getting this error Additional information: There is no row at position 0. but in my DB I have 60000 data of this table I...
24 Jan 2018 by OriginalGriff
For starters, don't do it like that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead. When you concatenate strings, you cause problems because SQL...
25 Apr 2018 by Frederic GIRARDIN
Since to the previous question I myself answered, that I had discovered the solution, but that I did not know how I could solve it, I told myself that the best thing was to ask this question separately for give everyone a chance to answer. So I summarize, I'm trying to find out, how to get the...
16 Oct 2018 by Member 10872518
I need to fetch data from datagridview to checkedlistbox while updating in windows form in C#. Data will be already stored in database (like:- A, B, C, D, )during insert operation, while updating i need to fetch the data from database to checkedlistbox, and the data should be checked. Data...
2 Dec 2018 by Member 13039327
Dear all, I am trying to update a dataset with multiple tables. However evertime I want to update, the first table that I want to update throws an error, that collumn doesn't excist in that table. This is indeed thru, but the collumn only excist in the last table I want to update. I did try to...
1 Dec 2018 by Member 13039327
Hello Richard That is the problem. Why is VB calling this row? I know it is saying column in the exception, but I assume it is addressing the row.But inside the code I am not addressing this row, only in the update for tbUser where there is such row. I am not using this column, never had. The...
1 Dec 2018 by Member 13039327
Hello Richard, I am using the debuger and everytime when it hits the da.update it is going in that error. If I remove the tbUsers int he da/ds then the error will be that rwAuthUser is not in the table. But then when I only update tbUserAuthorizations, it is going okay. And the above code is...
2 Dec 2018 by Member 13039327
Dear all, I found a way to make it work, but not sure if in the end it will not creating problems, like difference of collumn / row between DS and the Database. If then the Dataset, Dataadapter and Database are in sync. I now have combined ds.tables with a query for insert. ds.tables is/was...
15 Mar 2021 by TheBigBearNow
Hello everybody, I have a DataGrid that is being populated from a DataTable by a SQL database. My SQL creates a list of objects and I create the datatable and columns dynamically. I am trying to set the column width of each column so I can specify them to whatever width I want. My grid view is...
9 Apr 2019 by Member 14221689
These are two class files public class Salary { . . . public List tripAllowancedt { get; set; } } public class TripAllowanceDT { public int id { get; set; } public string BookingNumber { get; set; } ...
9 Apr 2019 by Gerry Schmitz
You're trying to pass a "collection" as a parameter; there is no such support. sc.Parameters.AddWithValue("AllowanceDT", EmployeeSalary.tripAllowancedt); SqlDbType Enum (System.Data) | Microsoft Docs[^]
21 Apr 2019 by leone
Hi, i have a disconnected ado.net code. I am deleting some rows from a datatable. And then acceptchanges over datatable and then update for physically saving over dataadapter. If i don't put following line everything works fine otherwise there is no actual change on database:...
21 Apr 2019 by Gerry Schmitz
"AcceptChanges" comes AFTER "Update". DataTable.AcceptChanges Method (System.Data) | Microsoft Docs[^]
21 Apr 2019 by leone
Ok brother i see. Thank you for your reply.
25 Jun 2019 by Member 14072220
Hi Everyone, this is 3rd forum I am posting this with no help whatsoever..... What I am trying to do is very simple but somehow it ends up being an impossible task... I am working on APP that has a prebuild formatted datagrid. When App runs DataGrid gets populated with Values. What I need is...
9 Aug 2020 by Garth J Lancaster
"i am begineer" - ok "i want urgent answer" - not ok - people on this site are volunteers, ie do not get paid - we are not your servants - I suggest you learn some manners I can't see why you're complicating things with a datatable - you seem...
12 Nov 2020 by stevenlam505
I've heard that you can use linked servers, however is there another approach using C#? For example, I have a table of 3000+ machines in table A with each having a serial number, location, name, and several more identifiers. However, on table B,...
12 Nov 2020 by CHill60
Yes, you can use Linked Servers. I've personally never had performance issues when using them (see comment from @PIEBALDconsult) but it is something to consider - have a look into OPENQUERY instead e.g. see Best Performer: Distributed query...
15 Mar 2021 by aherceo
public ProductsList() { InitializeComponent(); CreateProductList(); DataTable dt = DataTableProductList(productList); // it is assumed that productList is a public variable of type List ...
7 Dec 2021 by Member 15435322
I was wondering, what is the best way to create relationships between entities in a project that is being written from scratch, or specify what relationships to have between them? For example, as we can directly understand the relationship...
6 Feb 2022 by Member 12783008
Hi I have a need to insert records to either a database and currently using Microsoft Access. I have done some code, and roughly 10,000 records takes 12secs (using Access), I am wondering if I can improve my code in any way. I believe you...
6 Feb 2022 by OriginalGriff
See here: SqlBulkCopy Class (System.Data.SqlClient) | Microsoft Docs[^]
14 Feb 2022 by Blue Ocean
For all who are interested in the final solution that spanned two different questions, go here: https://www.codeproject.com/Questions/5325114/How-to-concatenate-a-multiple-field-combobox-selec
10 Oct 2022 by Prahlad Yeri
My situation involves batch updates to individual tables in an Sqlite database through ADO.NET objects. I use the `DataAdapter.Update()` method to push the changes which works well: DataTable changes = dataset.Tables[table].GetChanges(); ...
10 Oct 2022 by Prahlad Yeri
After a little experimenting, I found the solution to this myself. As strange as it may sound but it looks like `adapter.Update()` requires a dataset along with the actual table name in order for this to work. I was passing the table object...
7 Jan 2023 by mojtabahakimian
I use C# WPF, I am programming an accounting program with a SQL Server database, in this accounting program, data is inserted, updated, and deleted by the user directly in a data grid, which contains a textbox and Combobox elements. In an issue...
7 Jan 2023 by Graeme_Grant
Databinding with data models bound to the DataGrid. EntityFramework or Dapr is a cleaner and simpler database framework. There are plenty of Google searchable tutorials explaining how to do both.
5 Feb 2023 by Charm Mukuwane
Im trying to insert records into an SQL table through VB.Net. The Records are inserted but I get the following Error Message: The parameterized query '(@EmpName varchar(8000),@USDBasic money,@OtherUSDEarnings money,' expects the parameter...
5 Feb 2023 by OriginalGriff
Ignoring that the VB code won't even compile ... Look at the error message: The parameterized query '(@EmpName varchar(8000),@USDBasic money,@OtherUSDEarnings money,' expects the parameter '@EmpName', which was not supplied. That is pretty...
5 Nov 2012 by A N Saraf
I'm writing my Invoicing Application from Scratch and now want to make it more stable.I have a Form for Sale Invoicing, Here are the Tables related to i1. Table Name SP contains master register and invoice information having fields SPId, No, Date, Cust, TotalAmt2. Table Name Items...