PDA

View Full Version : مشکل در کد آپدیت اطلاعات دیتابیس



saeedhushmand
پنج شنبه 12 آبان 1390, 12:40 عصر
کد زیر برای اپدیت اطلاعاتم چی به کدم اضافه کنم تا هر سطری که اپدیت شد بهش توی ستون active کد 1 بزاره

چه کار کنم تا یک ستون از جدول دیتابیسم توی همه سطرهاش کد 0 داشته باشه



اینم کدم

SqlConnection myConn;
SqlCommand myComm;
StrConn = "SERVER=.;DATABASE=laberator;Integrated Security=True";
StrQury = "Update [sodor faktor] Set [shomare faktor]=@CodeH,[mande ghabli]=@CodeA,sumkarha=@CodeB,[sum faktor]=@CodeC,data1=@D1,data2=@D2,active=@F where active=N'" + "" + "' docter=N'" + comboBox1.Text + "' and [data vorod] between '" + maskedTextBox3.Text + "' and '" + maskedTextBox4.Text + "'";
myConn = new SqlConnection(StrConn);
myComm = new SqlCommand();
myComm.Connection = myConn;
myComm.CommandType = CommandType.Text;
myComm.CommandText = StrQury;
myComm.Parameters.Add("CodeB", SqlDbType.NVarChar, 50).Value = this.textBox6.Text;
myComm.Parameters.Add("CodeH", SqlDbType.NVarChar, 50).Value = this.textBox1.Text;
myComm.Parameters.Add("CodeA", SqlDbType.NVarChar, 50).Value = this.textBox5.Text;
myComm.Parameters.Add("CodeC", SqlDbType.NVarChar, 50).Value = this.textBox3.Text;
myComm.Parameters.Add("D1", SqlDbType.NVarChar, 50).Value = this.maskedTextBox3.Text;
myComm.Parameters.Add("D2", SqlDbType.NVarChar, 50).Value = this.maskedTextBox4.Text;

 
myConn.Open();
myComm.ExecuteNonQuery();
myConn.Close();
 
 
 
 
comboBox1.Focus();
}

ممنون..