Nastaran_a
20-06-2007, 00:24
سلام
یه سوال در مورد دستور insert در C#.net دارم .من دارم یه پروژه انبارداری می نویسم البته به صورت سه لایه ای
یه مشکل با دستور insert داشتم.من کد زیر رو نوشتم اگه به نظرتون جاییش مشکل داره بهم بگید.
در لایه DataAccess
public int EnterFish(int txtCustomerCode, int txtFishNo, string txtFishDate, int txtFishPay, string txtFishPayment, string txtBankName, int txtAccount)
{
انبار_داری.Class.FormPay FPay = new انبار_داری.Class.FormPay(txtCustomerCode, txtFishNo,txtFishDate,txtFishPay,txtFishPayment,tx tBankName,txtAccount);
try
{
string Connection = ConnectionSTR();//Connection String
string Str = string.Format("INSERT INTO Fish (shomare fish,tarikhe fish,mablaghe fish,variz konande fish,name bank,shomare hesab,code moshtari) VALUES ({0},'{1}',{2},'{3}','{4}',{5},{6})", FPay.FishNo,FPay.FishDate,FPay.FishPay,FPay.FishPa yment,FPay.BankName,FPay.Account,FPay.CustomerCode );
SqlDataAdapter da = new SqlDataAdapter(Str, new SqlConnection(Connection));
Num = 1;
return Num;
}
catch (Exception ex)
{
Num = -1;
return Num;
}
}
روی باتن فرم
private void fish1_Click_Save()
{
int Num;
try
{
Num = DA.EnterFish(Convert.ToInt32(fizz1.CustomerCode.Te xt),Convert.ToInt32(fish1.FishNum.Text),fish1.Fish Date.Text,Convert.ToInt32(fish1.FishSum.Text),fish 1.FishName.Text,fish1.BankName.Text,Convert.ToInt3 2(fish1.Account.Text));
if (Num == -1)
{
MessageBox.Show("êç§ں© ¥ï¥ ©ں يں©§ ëêںïï§");
}
else if (Num == 1)
{
MessageBox.Show("ںàںهى ک©§ë ں êيهçï¢ ںë¤ںê ¬§");
}
}
catch (Exception ex)
{
MessageBox.Show("êç§ں© ¥ï¥ ©ں §©يë هïé§ىں يں©§ ëêںïï§");
}
}
این چرت وپرت ها فارسی بوده این جوری شده.
در ضمن پیغام بهم میده که اضافه شده ولی توی جدول هام چیزی نیست. اگه کسی می تونه به من کمک کنه.
متشکرم
یه سوال در مورد دستور insert در C#.net دارم .من دارم یه پروژه انبارداری می نویسم البته به صورت سه لایه ای
یه مشکل با دستور insert داشتم.من کد زیر رو نوشتم اگه به نظرتون جاییش مشکل داره بهم بگید.
در لایه DataAccess
public int EnterFish(int txtCustomerCode, int txtFishNo, string txtFishDate, int txtFishPay, string txtFishPayment, string txtBankName, int txtAccount)
{
انبار_داری.Class.FormPay FPay = new انبار_داری.Class.FormPay(txtCustomerCode, txtFishNo,txtFishDate,txtFishPay,txtFishPayment,tx tBankName,txtAccount);
try
{
string Connection = ConnectionSTR();//Connection String
string Str = string.Format("INSERT INTO Fish (shomare fish,tarikhe fish,mablaghe fish,variz konande fish,name bank,shomare hesab,code moshtari) VALUES ({0},'{1}',{2},'{3}','{4}',{5},{6})", FPay.FishNo,FPay.FishDate,FPay.FishPay,FPay.FishPa yment,FPay.BankName,FPay.Account,FPay.CustomerCode );
SqlDataAdapter da = new SqlDataAdapter(Str, new SqlConnection(Connection));
Num = 1;
return Num;
}
catch (Exception ex)
{
Num = -1;
return Num;
}
}
روی باتن فرم
private void fish1_Click_Save()
{
int Num;
try
{
Num = DA.EnterFish(Convert.ToInt32(fizz1.CustomerCode.Te xt),Convert.ToInt32(fish1.FishNum.Text),fish1.Fish Date.Text,Convert.ToInt32(fish1.FishSum.Text),fish 1.FishName.Text,fish1.BankName.Text,Convert.ToInt3 2(fish1.Account.Text));
if (Num == -1)
{
MessageBox.Show("êç§ں© ¥ï¥ ©ں يں©§ ëêںïï§");
}
else if (Num == 1)
{
MessageBox.Show("ںàںهى ک©§ë ں êيهçï¢ ںë¤ںê ¬§");
}
}
catch (Exception ex)
{
MessageBox.Show("êç§ں© ¥ï¥ ©ں §©يë هïé§ىں يں©§ ëêںïï§");
}
}
این چرت وپرت ها فارسی بوده این جوری شده.
در ضمن پیغام بهم میده که اضافه شده ولی توی جدول هام چیزی نیست. اگه کسی می تونه به من کمک کنه.
متشکرم