PDA

View Full Version : خطا در ExecuteNonQuery



Dadvar
سه شنبه 22 دی 1394, 10:48 صبح
با سلام

کد زیر
sqls.update("insert into Reject values('" + txtdp.Text + "','" + txtmp.Text + "','" + txtlocalrej.Text + "','"
+ txtthic.Text + "','" + txtwidth.Text + "','" + txtlenght.Text + "','" + txtweight.Text + "','" + txtdef.Text + "','"
+ txtdeftype.Text + "','"
+ txtsendplate.Text + "','"
+ txtdaterej.Text + "','"
+ txtdatetimerej.Text + "','"
+ txtshortprog.Text + "','"
+ txtalloy.Text + "','"
+ txtheatno.Text + "','"
+ txtslabid.Text + "','"
+ txtorder.Text + "','"
+ txtdatepro.Text + "')");




با کلاس
public class sqlserver
{
SqlConnection con;
SqlDataAdapter da ;
SqlCommand sc;


public sqlserver(string server,string dbname)
{
con = new SqlConnection("Data Source=" + server + ";Initial Catalog=" + dbname + ";Integrated Security=True");
da = new SqlDataAdapter();
sc = new SqlCommand();
da.SelectCommand = new SqlCommand();
da.SelectCommand.Connection = con;
sc.Connection = con;
}
~sqlserver()
{
con.Close();
}

public DataTable select(string str_q)
{
DataTable temp = new DataTable();
da.SelectCommand.CommandText = str_q;
con.Open();
da.Fill(temp);
con.Close();
return temp;
}
public int update(string str_q)
{
int result;
sc.CommandText = str_q;
con.Open();
result = sc.ExecuteNonQuery();
con.Close();
return result;
}




میخواستم وارد بانک کنم خطای زیر رو میده

result = sc.ExecuteNonQuery();

میخواستم ببینم مشکل چی هست؟

محمد آشتیانی
سه شنبه 22 دی 1394, 12:56 عصر
سلام
چه خطایی میده دقیقا؟ احتمالا توی کوئریت کوتیشن کم یا زیاد گذاشتی و یا مثلا مقدار integer رو هم داخل کوتیشن گذاشتی
متن خطا رو اینجا بذار لطفا

aslan
سه شنبه 22 دی 1394, 13:53 عصر
+ txtdatepro.Text + "')";