TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
698
1.3k
217.6k
Why I should always close my program before another action?
Jan 23 2017 11:57 AM
Hi!
I wrote these codes. Its delete all replicated row into my table. But the thing is when I press the button to delete the repeated row. Its works! But the repeated action restart to work properly only when I close the program completly.
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Foods\Foods\App_Data\office.mdb;Persist Security Info=False");
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("select * from movimentoDetalhados", con);
con.Open();
da.Fill(ds, "movimentoDetalhados");
for (int i = 0; i < ds.Tables["movimentoDetalhados"].Rows.Count; i++)
{
DataRow row = ds.Tables["movimentoDetalhados"].Rows[i];
k1++;
for (int j = k1; j < ds.Tables["movimentoDetalhados"].Rows.Count; j++)
{
DataRow row2 = ds.Tables["movimentoDetalhados"].Rows[j];
if (row.ItemArray.GetValue(1).ToString() == row2.ItemArray.GetValue(1).ToString())
{
if (row.ItemArray.GetValue(2).ToString() == row2.ItemArray.GetValue(2).ToString())
{
id1 = int.Parse(row2.ItemArray.GetValue(0).ToString());
deletedupes(id1);
}
}
}
}
con.Close();
}
private void deletedupes(int num)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\LunaFood\LunaFoods\App_Data\office.mdb;Persist Security Info=False");
con.Open();
OleDbCommand c = new OleDbCommand("Delete from movimentoDetalhados where id =?", con);
c.Parameters.AddWithValue("id", num);
c.ExecuteNonQuery();
con.Close();
}
Reply
Answers (
3
)
Any idea how dis form is being submit
How to prevent Automatic Redirection without Permission