hi

I have filled my datasetfrom my sql db then used that data to show at crystal report, when i go back again to fill it with another data it show to me the old one why ? how can i solve this problem ??

Best Regards

In your table adapter declaration use:

MyTableAdapter.ClearBeforeFill = true;

if i have this code :

public static DataSet ds = new DataSet();

 if ( Convert.ToInt32(SelectedRow.Cells[1].Value).Equals(2))
            {
                flag = 2;
                SQLSelectStatment = "SELECT * FROM News_Agency WHERE ID=" + (SelectedRow.Cells[0].Value).ToString();

                try
                {
                    SqlCommand sqlCMD = new SqlCommand(SQLSelectStatment, conn);
                    sqlCMD.CommandType = CommandType.Text;

                    SqlDataAdapter adp = new SqlDataAdapter(sqlCMD);

                    adp.Fill(ds);
                    ds.Tables[0].TableName = "SelectNewsAgency";
                }
                catch (Exception exp)
                {
                    throw new ArgumentException(exp.Message);
                }
                finally
                {
                    conn.Close();
                }
            }

how can I do (MyTableAdapter.ClearBeforeFill = true;) in this code ???

best regards

I have solved this problem with two rows of code :

ds.Reset();
adp.Fill(ds);
ds.Tables[0].TableName = "SelectNewsAgency";
ds.AcceptChanges();

with Reset() & AcceptChanges()
Thanks for every one

Best Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.