behzadk
سه شنبه 22 آبان 1386, 09:28 صبح
با سلام
اشکال این کد چیه ؟
string command,field;
field = "code,transact,type,area,address,spc,u_spc,price,ej are,rahn,credi,pish,bis,home,agri,t_type,working,c on_work,f_count,count_v,floors,water,w_count,elect ,gas,e_count,g_count,phonep_count,bedcount";
SqlConnection cnn = new SqlConnection("data source=(local);database=houses;uid=sa;password=1;");
SqlCommand cmd = new SqlCommand();
command = "insert into houses (" + field + ") valuses('20'," + (comboBox1.SelectedIndex) + "," + (comboBox2.SelectedIndex) + "," + (Convert.ToInt32(textBox24.Text)) + "," + "'" + textBox1.Text + "'" + "," + (Convert.ToInt32(textBox6.Text)) + "," + (Convert.ToInt32(textBox7.Text)) + "," + (Convert.ToDouble(textBox2.Text)) + "," + (Convert.ToDouble(textBox4.Text)) + "," + (Convert.ToDouble(textBox3.Text)) + "," + (Convert.ToDouble(textBox5.Text)) + "," + (check(checkBox1)) + "," + (check(checkBox2)) + "," + (check(checkBox3)) + "," + (check(checkBox4)) + "," + "'" + textBox8.Text + "'" + "," + (check(checkBox5)) + "," + "'" + textBox9.Text + "'" + "," + (Convert.ToInt32(textBox10.Text)) + "," + (Convert.ToInt32(textBox11.Text)) + "," + (Convert.ToInt32(textBox12.Text)) + "," + (check(checkBox7)) + "," + (Convert.ToInt16(textBox13.Text)) + "," + (check(checkBox8)) + "," + (Convert.ToInt16(textBox14.Text)) + "," + (check(checkBox9)) + "," + (Convert.ToInt16(textBox15.Text)) + "," + (check(checkBox10)) + "," + (Convert.ToInt16(textBox16.Text)) + "," + (Convert.ToInt16(textBox18.Text)) + ")";
cmd.CommandText = command;
cmd.Connection = cnn;
cnn.Open();
if (cmd.ExecuteNonQuery() == 0)
MessageBox.Show("عمل ثبت با موفقیت انجام شد");
else
MessageBox.Show("عمل ثبت با شکست مواجه شد");
cnn.Close();
اشکال این کد چیه ؟
string command,field;
field = "code,transact,type,area,address,spc,u_spc,price,ej are,rahn,credi,pish,bis,home,agri,t_type,working,c on_work,f_count,count_v,floors,water,w_count,elect ,gas,e_count,g_count,phonep_count,bedcount";
SqlConnection cnn = new SqlConnection("data source=(local);database=houses;uid=sa;password=1;");
SqlCommand cmd = new SqlCommand();
command = "insert into houses (" + field + ") valuses('20'," + (comboBox1.SelectedIndex) + "," + (comboBox2.SelectedIndex) + "," + (Convert.ToInt32(textBox24.Text)) + "," + "'" + textBox1.Text + "'" + "," + (Convert.ToInt32(textBox6.Text)) + "," + (Convert.ToInt32(textBox7.Text)) + "," + (Convert.ToDouble(textBox2.Text)) + "," + (Convert.ToDouble(textBox4.Text)) + "," + (Convert.ToDouble(textBox3.Text)) + "," + (Convert.ToDouble(textBox5.Text)) + "," + (check(checkBox1)) + "," + (check(checkBox2)) + "," + (check(checkBox3)) + "," + (check(checkBox4)) + "," + "'" + textBox8.Text + "'" + "," + (check(checkBox5)) + "," + "'" + textBox9.Text + "'" + "," + (Convert.ToInt32(textBox10.Text)) + "," + (Convert.ToInt32(textBox11.Text)) + "," + (Convert.ToInt32(textBox12.Text)) + "," + (check(checkBox7)) + "," + (Convert.ToInt16(textBox13.Text)) + "," + (check(checkBox8)) + "," + (Convert.ToInt16(textBox14.Text)) + "," + (check(checkBox9)) + "," + (Convert.ToInt16(textBox15.Text)) + "," + (check(checkBox10)) + "," + (Convert.ToInt16(textBox16.Text)) + "," + (Convert.ToInt16(textBox18.Text)) + ")";
cmd.CommandText = command;
cmd.Connection = cnn;
cnn.Open();
if (cmd.ExecuteNonQuery() == 0)
MessageBox.Show("عمل ثبت با موفقیت انجام شد");
else
MessageBox.Show("عمل ثبت با شکست مواجه شد");
cnn.Close();