I am creating a distributed application in C# using a database. The connection data source is: Microsoft SQL Server Compact 3.5 (.NET Framework Data Provider for Microsoft SQL Server Compact 3.5)
Here's what happens:
If I run this application locally, in design mode, it stores the data. The data will remain in the table until I try to view the contents of the table by using the below menu:
When I do that, the table shows no records. After I do that and re-run my app, the data is all gone. If I don't try to view it, the data remains no matter how many times I stop and start the app.
Weird?
Anyway, once I build and publish my app, using the Build menu, the app will not retain any information I enter at all.
Any ideas why this might happen?
Below is a piece of code that writes info to one of the tables, just in case it's pertinent.
private void fF_tblParamsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
SqlCeConnection con = new SqlCeConnection();
con.ConnectionString = FileFinder.Properties.Settings.Default.Database1ConnectionString;
con.Open();
//Create the SQL string and then add the variables
SqlCeCommand com = new SqlCeCommand("update [FF_tblParams] set FileSize=@FLen, DateLastAccessedLT=@FAccessLT, DateLastAccessedGT=@FAccessGT, DateLastModifiedLT=@FWriteLT, DateLastModifiedGT=@FWriteGT", con);
//SqlCeCommand com = new SqlCeCommand("INSERT INTO FF_tblParams (FileSize, DateLastAccessedLT, DateLastAccessedGT, DateLastModifiedLT, DateLastModifiedGT) VALUES (@FLen, @FAccessLT, @FAccessGT, @FWriteLT, @FWriteGT)", con);
com.Parameters.AddWithValue("@FLen", fileSizeTextBox.Text);
com.Parameters.AddWithValue("@FAccessLT", dateLastAccessedLTDateTimePicker.Text);
com.Parameters.AddWithValue("@FAccessGT", dateLastAccessedGTDateTimePicker.Text);
com.Parameters.AddWithValue("@FWriteLT", dateLastModifiedLTDateTimePicker.Text);
com.Parameters.AddWithValue("@FWriteGT", dateLastModifiedGTDateTimePicker.Text);
com.ExecuteNonQuery();
com.Dispose();
con.Close();
}
This is my first ever app using WinForms, so please pardon what might be a n00b question.
Aucun commentaire:
Enregistrer un commentaire