Saving Dataset Back to Database

Madz

Well-known member
Joined
Jan 22, 2003
Messages
155
I am having a problem
I have a connections which i accessing data from a database. after connecting a database i am filling a dataset with a table and showing results in a Grid. i grid i change many values
but these values are not commited to database

is there any way so i could be able to commit that dataset back to there from where it was originated
 
Whats your code

Look at the Update method with the CommandBuilder using the dataadapter this will do what you want

Andy
 
I am working on a project with which an administrator can enter informaton about his dealers and distributors. this is code of customers table

this is the Dataset which i am using
Code:
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="dtCustomers" targetNamespace="http://www.tempuri.org/dtCustomers.xsd" xmlns:mstns="http://www.tempuri.org/dtCustomers.xsd" xmlns="http://www.tempuri.org/dtCustomers.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
	<xs:element name="dtCustomers" msdata:IsDataSet="true">
		<xs:complexType>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="Customers">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Name" type="xs:string" />
							<xs:element name="Distributor" type="xs:boolean" />
							<xs:element name="Dealer" type="xs:boolean" />
							<xs:element name="Address" type="xs:string" />
							<xs:element name="City" type="xs:string" />
							<xs:element name="Phone" type="xs:string" />
							<xs:element name="Fax" type="xs:string" minOccurs="0" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>

next with a search button i am doing this filling the Dataset and Refreshing the Results in a Grid

Code:
dsShowCustomers.Clear()
        On Error Resume Next
        If Not cboCity.Text = "" Then  cbocity is a Combo Box in which some cities are listed.
            cmdSelectCustomer.CommandText = "Select Name, Distributor, Dealer, Address, City, Phone, Fax From Customers Where City = " & cboCity.Text & ""
            Debug.WriteLine(cmdSelectCustomer.CommandText)
        Else
            cmdSelectCustomer.CommandText = "Select Name, Distributor, Dealer, Address, City, Phone, Fax From Customers"
        End If
        mySQL.Open()
        cmdSelectCustomer.ExecuteNonQuery()
        mySQL.Close()
        myAdapter.Fill(dsShowCustomers)
       datagrid here        
        dgCustomers.Refresh()

Here i am able to generate the Dataset i am making changes in Data in DataGrid but i dont know how to send it back to Database
here myAdapter.update(dataset) doesnot working.
Is there any solution
 
Back
Top