بانک اطلاعات در C#
سلام وقتی دکمه ثبت اطلاعات رو در برنامه ی زیر می زنم
۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۱۰ ۱۱ ۱۲ ۱۳ ۱۴ ۱۵ ۱۶ ۱۷ ۱۸ ۱۹ ۲۰ ۲۱ |
oleDbCommand1.Parameters.Clear(); <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.CommandText = </span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"insert into ali(name=@n,password=@p,mobile=@m,email=@e,code=@c) "</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">;</span></span> <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.Parameters.AddWithValue(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"@n"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">, textBox1.Text);</span></span> <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.Parameters.AddWithValue(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"@p"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">, textBox2.Text);</span></span> <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.Parameters.AddWithValue(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"@m"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">, textBox3.Text);</span></span> <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.Parameters.AddWithValue(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"@e"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">, textBox4.Text);</span></span> <span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small"> oleDbCommand1.Parameters.AddWithValue(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"@c"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">, textBox5.Text);</span></span> oleDbConnection1.Open(); oleDbCommand1.ExecuteNonQuery(); oleDbConnection1.Close(); <span style="color: #2b91af;font-family: Consolas;font-size: small"><span style="color: #2b91af;font-family: Consolas;font-size: small"><span style="color: #2b91af;font-family: Consolas;font-size: small">MessageBox</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">.Show(</span></span><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small"><span style="color: #a31515;font-family: Consolas;font-size: small">"ثبت شد"</span></span></span><span style="font-family: Consolas;font-size: small"><span style="font-family: Consolas;font-size: small">);</span></span> |
در خط
۱ |
oleDbCommand1.ExecuteNonQuery(); |
خطا میده . مشکل از کجاست .در ضمن بانک اطلاعاتی رو درست به معرفی کردم
پاسخ ( 1 )
سلام
چرا هم مقدار Value و هم نام جداول رو کنار هم نوشتید ؟
کد زیر را امتحان کنید :
موفق باشید