I have this code in a web service, but when I try to update the database using the second method (setContacts), it does not update at all, although I do not get an error message.
[WebMethod]
public DataSet getContacts()
{
using (SqlConnection con = new SqlConnection(connString))
{
DataSet ds = new DataSet("Contacts");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da = new SqlDataAdapter("SELECT * FROM Contacts", con);
da.Fill(ds);
return ds;
};
}
[WebMethod]
public void setContacts(DataSet data)
{
using (SqlConnection con = new SqlConnection(connString))
{
DataSet ds = new DataSet("Contacts");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da = new SqlDataAdapter("SELECT * FROM Contacts", con);
da.Update(data, "Contacts");
};
}
Loading
Kirtan PatelPosted Feb 15, 2010, 12:07 PM
Here is sample Project I have provided with database that i coded for you !! that update database from webservice
just take a look
i called UpdateMethod Like below ..
protected void btnUpdate_Click(object sender, EventArgs e)
{
string Username = TextBox1.Text;
string newPassword = TextBox2.Text;
localhost.Service1 srv = new localhost.Service1();
// Update the Userpassword By Calling webmethod of service
srv.UpdateUser(Username, newPassword);
}