Click here to Skip to main content
15,891,873 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more: , +
i have a big problem and ask many question to fix my problems but : i have a bad problem in my APP !

in this app the update button (see in picture in rar file) in forms is not work !

if you D.click in my button you see the update code!
the .rar file has pictures to help you where is the problem !
please restore my database and see my App & if you can find problem please tell me to fix it !

for EX: the code is in form5_1.cs (see update codes)

<pre lang="cs">
       private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا سطر را وارد کنید");
                }
                else if (textBox2.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا شماره ی استاد را وارد کنید");
                }
                else if (textBox3.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا شماره ی درس را وارد کنید");
                }
                else if (textBox4.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا روز را وارد کنید");
                }
                else if (textBox5.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا تاریخ را وارد کنید");
                }
                else if (textBox6.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا زمان ورود به کلاس را وارد کنید");
                }
                else if (textBox6.Text == "")
                {
                    MessageBox.Show("کاربر گرامی لطفا زمان خروج از کلاس را وارد کنید");
                }
                else
                {
                    objcommand = new SqlCommand();
                    objcommand.Connection = objconnection;
                    objcommand.CommandType = CommandType.Text;
                    objcommand.CommandText = "UPDATE meet set  pnumber=@2 sec_numbers=@3 day=@4 date=@5 enter_time=@6 finish_time=@7 where row=@1";
                    objcommand.Parameters.AddWithValue("@1", textBox1.Text);
                    objcommand.Parameters.AddWithValue("@2", textBox2.Text);
                    objcommand.Parameters.AddWithValue("@3", textBox3.Text);
                    objcommand.Parameters.AddWithValue("@4", textBox4.Text);
                    objcommand.Parameters.AddWithValue("@5", textBox5.Text);
                    objcommand.Parameters.AddWithValue("@6", textBox6.Text);
                    objcommand.Parameters.AddWithValue("@7", textBox7.Text);
                    objconnection.Open();
                    objcommand.ExecuteNonQuery();
                    objconnection.Close();
                    objcommand.Parameters.Clear();
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                    textBox4.Text = "";
                    textBox5.Text = "";
                    textBox6.Text = "";
                    textBox7.Text = "";
                    this.meetTableAdapter.Fill(this.presentDataSet_meets.meet);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                objconnection.Close();
            }
        }









Full APP+Database:(Download)
English version ! ! !

=== > http://www.upload.iran-forum.ir/uploads/1301444319.rar[^] < ===
Posted
Updated 29-Mar-11 0:00am
v4

1 solution

First thing that isn't going to happen: I won't download a random rar file from a stranger. I have no idea what it contains, and I am not about to find out.
If the code inside is relevant, then post the relevant fragments in your question.

Secondly, even if I did download and example your code, do you realy think I am going to spend that much time wading through an entire app which uses default names for everything?
form5_1.cs
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";

I strongly suggest you start using sensible names as a minimum (and some form of commenting would help) if you want help like that!

"download
http://vistaupload.com/...
or
http://www.upload.iran-forum.ir/uploads/...

the update Button in professor and course and . .. . does'nt work"


I said: I'm not going to download it!

However I will tell you what the probable problem is: commas.
Instead of:
objcommand.CommandText = "UPDATE meet set  pnumber=@2 sec_numbers=@3 day=@4 date=@5 enter_time=@6 finish_time=@7 where row=@1";

Try:
objcommand.CommandText = "UPDATE meet SET  pnumber=@2, sec_numbers=@3, day=@4, date=@5, enter_time=@6, finish_time=@7 WHERE row=@1";


If you had posted the error message, like I asked, it might have been obvious sooner...:laugh:
 
Share this answer
 
v2
Comments
my name is coder ! ! ! 29-Mar-11 5:00am    
okif you see the picture you should be Understand my problem ! ! !
my name is coder ! ! ! 29-Mar-11 5:01am    
when i click that Button , APP or Sql server take a problem and can't update my DB !

i'll be change the names !
OriginalGriff 29-Mar-11 5:04am    
Does it give an error message? If so, then what?
my name is coder ! ! ! 29-Mar-11 5:34am    
wait to upload English Verion of my APP ! :D
walterhevedeich 29-Mar-11 5:41am    
high 5.

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