I have an Infopath form, that eventually will be published to Sharepoint, that uses a web service data connection to retrieve from and update records to a SQL database. When I preview the form, the web service pulls records from the data base according to my SQL Command, yet it pulls old data. I can update the data, which submits successfully, and I check in SQL Server Management Studio, and the update is successful. Yet when I preview the form again, I see the data that was originally retrieved the first time I previewed the form, not the new data that was just updated. My guess is that I need to flush the dataset and then refill it, but im not sure the code to do so. Here is my code for the web method that retrieves the data from the database:
[
WebMethod]public DataSet GetUsers(string UserName)
{
DataSet ds = null;
//Create a Connection to the SQL Server Database
using (SqlConnection conn =new SqlConnection("Server=XXXX;Database=XXXXX;Trusted_Connection=XXXX"))
{
// Open a connection to the SQL Server database.
conn.Open();
// Retrieve the users from the SQL Server database.using (SqlCommand cmd =new SqlCommand("SELECT HomeNumber, PrimaryEmail, WorkNumber FROM dbo.CONTACT WHERE accountname like '%" + UserName + "';", conn))
// Fill the Dataset
{
SqlDataAdapter adp = new SqlDataAdapter(cmd);ds = new DataSet();
adp.Fill(ds);
}
// Close the connection.
conn.Close();
}
return ds;
}
}
}
As im sure you can tell I'm a noob when it comes to programming, so any help you can give would be great, Thanks!