c# - DataAdapter update method - which connection does it use? -


Sorry for the stupid question probably because I did not find anything about it, it is completely clear about it and I'm just looking at the blind !!

I am trying to update the table of data from a database to a database in the database. Update (dataset)

But there is no possibility to set up the connection, DA should be used.

How to connect the DA to DB, where is it? Or do I misunderstand the concept of DataAdapter?

My current code is like this:

  Protected Dataset updateDataset Ds {DataSet dsChanges = new DataSet (); SqlDataAdapter da = New SqlDataAdapter (); DsChanges = D. Gate changel (); // Update dataset de. Update (dsChanges); Ds.Merge (dsChanges); Return ds; }  

I wrote this and how it works (or if) it became suspicious ... I have tested it yet, because I have some Other code will be written

Thanks, PPL, Stack Overflow FTW!

A SQLData adapter is a SQL command object, which has a squanecting object that is connected to it.

How to you have the option to go through the constructor, to go about it, as

FTA :

  Public Fixed SqlDataAdapter CreateCustomerAdapter (SqlConnection Connection) {SqlDataAdapter Adapter = New SqlDataAdapter (); // Create Command Create SQL Commands Command = New SQL Commands ("Select from customers" + "where country = @ country and city = @ Sita", connection); // Add parameter to SelectCommand command Parameter. Ed ("@ Country", SKLDB type., Narkher, 15); Command. Parameters.ed ("@ City", SKLDB Type, Worker, 15); Adapter.SelectCommand = Order; // InsertCommand Create Command = New SQL Command ("Customer ID (Customer Id, Company Name)" + "Value (@Castardidide, @companyname)", connection); // Add parameter for InsertCommand command. Parameter. Ed ("@ Customer ID", SQLDB type, mark, 5, "custom ID"); Command. Parameter. Ed ("@ company name", SCLDB type.NVarChar, 40, "company name"); Adapter.InsertCommand = Command; // Update Command command = New SQL Commands ("Customers Update Customers to Customer ID = @CustomerID," + "Company Name = @CompanName" + "where customerID = @oldCustomerID", connection); // Add parameter to UpdateCommand command. Parameter. Ed ("@ Customer ID", SQLDB type, mark, 5, "custom ID"); Command. Parameter. Ed ("@ company name", SCLDB type.NVarChar, 40, "company name"); SqlParameter parameter = command.Parameters.Add ("@oldCustomerID", SqlDbType.NChar, 5, "Customer ID"); Parameter. SourceVersion = DataRowVersion.Original; Adapter.UpdateCommand = Order; // DeleteCommand Create Command = New SQL Commands ("Remove from Customer ID in Customer ID where Customer ID = @CustomerID", connection); // Add parameter for DeleteCommand parameter = command. Parameter.ed ("@CustomerID", SQLDB Type, Mark, 5, "Customer ID"); Parameter. SourceVersion = DataRowVersion.Original; Adapter.DeleteCommand = Order; Return adapter; }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -