Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This My Code:
C#
SqlCommand cmd2 = new SqlCommand("InsertCountCode", con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@count", txtStart.Text);
cmd2.Parameters.AddWithValue("@po", TxtPo.Text);
cmd2.Parameters.AddWithValue("@maxcounter", TxtMax.Text);
cmd2.Parameters.AddWithValue("@Style", comboStyle.Text);

con2.Open();
cmd2.ExecuteNonQuery();

Some Time This Code Takes 1 Minute
Or Tow Minute

How Can Complete progress bar after Insert Data In Sql
Depend Finish Execute Query
Posted
Updated 19-Oct-15 21:26pm
v2

1 solution

 
Share this answer
 
Comments
Member 11280947 20-Oct-15 3:36am    
Thank You First .
How Can Use This In My Code




// Loop through all files to copy.
for (int i = 1; i <= dt.Rows.Count; i++)
{
bool result=InsertUserdetails(Username);---------------Explain This Please
// Copy the file and increment the ProgressBar if successful.
if(result== true)
{
// Perform the increment on the ProgressBar.
Progressbar1.PerformStep();
}
}
Gokulprasad05 20-Oct-15 5:06am    
could you send ur full coding
Member 11280947 20-Oct-15 6:20am    
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con2 = new SqlConnection(CS))
{
SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM [TestCodeTBL] WHERE ([CodeNumbber] ='" + TxtPo.Text + "') ", CS);

DataTable dt2 = new DataTable();
sda2.Fill(dt2);
if (dt2.Rows.Count > 0)
{
MessageBox.Show("This Data Already Exists");
}
else
{

// Set Minimum to 1 to represent the first file being copied.
progressBar1.Minimum = 1;
// Set Maximum to the total number of Users created.
progressBar1.Maximum = dt2.Rows.Count;
// Set the initial value of the ProgressBar.
progressBar1.Value = 1;
// Set the Step property to a value of 1 to represent each user is being created.
progressBar1.Step = 1;



SqlCommand cmd2 = new SqlCommand("InsertCountCode", con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@count", txtStart.Text);
cmd2.Parameters.AddWithValue("@po", TxtPo.Text);
cmd2.Parameters.AddWithValue("@maxcounter", TxtMax.Text);
cmd2.Parameters.AddWithValue("@Style", comboStyle.Text);


con2.Open();
cmd2.ExecuteNonQuery();



// Loop through all files to copy.
for (int i = 1; i <= dt2.Rows.Count; i++)
{
bool result = InsertUserdetails(Username);--------------Problem Here
// Copy the file and increment the ProgressBar if successful.
if (result == true)
{
// Perform the increment on the ProgressBar.
progressBar1.PerformStep();
}
}

MessageBox.Show("Saved");
BtnNew.Enabled = true;
btnSave.Enabled = false;
}

}
Gokulprasad05 20-Oct-15 7:26am    
Private void LoadStudentDetail()
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con2 = new SqlConnection(CS))
{
SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM [TestCodeTBL] WHERE ([CodeNumbber] ='" + TxtPo.Text + "') ", CS);

DataTable dt2 = new DataTable();
sda2.Fill(dt2);
if (dt2.Rows.Count > 0)
{
MessageBox.Show("This Data Already Exists");
}
else
{

// Set Minimum to 1 to represent the first file being copied.
progressBar1.Minimum = 1;
// Set Maximum to the total number of Users created.
progressBar1.Maximum = dt2.Rows.Count;
// Set the initial value of the ProgressBar.
progressBar1.Value = 1;
// Set the Step property to a value of 1 to represent each user is being created.
progressBar1.Step = 1;



SqlCommand cmd2 = new SqlCommand("InsertCountCode", con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@count", txtStart.Text);
cmd2.Parameters.AddWithValue("@po", TxtPo.Text);
cmd2.Parameters.AddWithValue("@maxcounter", TxtMax.Text);
cmd2.Parameters.AddWithValue("@Style", comboStyle.Text);


con2.Open();
cmd2.ExecuteNonQuery();



// Loop through all files to copy.
for (int i = 1; i <= dt2.Rows.Count; i++)
{
bool result = InsertUserdetails(Username);--------------Problem Here
// Copy the file and increment the ProgressBar if successful.
if (result == true)
{
// Perform the increment on the ProgressBar.
progressBar1.PerformStep();
}
}

MessageBox.Show("Saved");
BtnNew.Enabled = true;
btnSave.Enabled = false;
}

}

}

protected void btnSubmit_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
LoadStudentDetail();
}

Please remove progress bar coding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900