PDA

View Full Version : علت این پیغام چیه؟



ehsan7007
دوشنبه 26 تیر 1391, 10:45 صبح
سلام.
وقتی برناممو اجرا می کنم و در تکست باکس ها متن می نویسم و سپس روی سیو کلیک می کنم به جای ذخیره این پنجره می یاد:

http://rezashahabi.persiangig.com/2.PNG

طرح برنامم اینه:

http://rezashahabi.persiangig.com/1.PNG

و کد برنامم :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication16
{
public partial class Form1 : Form
{


private System.Windows.Forms.TextBox money;
private System.Windows.Forms.TextBox type;
private System.Windows.Forms.DataGrid DataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;


#region "Variabels"
string nam, famil;
#endregion
#region "FormLoad"



private void Form1_Load(System.Object sender, System.EventArgs e)
{

System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("fa-ir");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language);

DataTable dt = new DataTable();

DataBase db = new DataBase();

dt = db.MySelect("select * from telephon");
DataGrid1.DataSource = dt;
}
#endregion

public Form1()
{
InitializeComponent();
}


private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"

money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();




#endregion
}
private void save_click(object sender, EventArgs e)
{
#region "Darj dar bank"

DataBase db = new DataBase();
db.DoCommand("insert into DataTable1 values('" + type.Text + "','" + money.Text + "','" + "')");

Form1_Load(sender, e);
MessageBox.Show("Inserted");
#endregion

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"

money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();




#endregion

}

private void money_TextChanged(object sender, EventArgs e)
{

}

private void type_TextChanged(object sender, EventArgs e)
{

}
}
}



مشکل چیه؟؟

ehsan7007
دوشنبه 26 تیر 1391, 12:58 عصر
میشه لطفا به لاتین بنویسید.

دو ستون داره.

tooraj_azizi_1035
دوشنبه 26 تیر 1391, 15:11 عصر
سلام
این دیگه چیه؟
'" + "')"
آخر دستور Insert؟

ehsan7007
دوشنبه 26 تیر 1391, 15:14 عصر
خب اشتباه کردم دیگه!!!!
:اشتباه:

ehsan7007
دوشنبه 26 تیر 1391, 15:32 عصر
این رو هم درست کردم ولی بازم موقع سیو اطلاعات همون پنجره می یاد و من continue رو می زنم و بعدش برنامم بسته می شه.

ehsan7007
دوشنبه 26 تیر 1391, 15:56 عصر
کسی نمی تونه کمکم کنه؟
برام مهمه ها؟:گریه::گریه::گریه:گریه:

aslan
دوشنبه 26 تیر 1391, 16:18 عصر
قسمتهای SAVE و DoCommand را اینجا بذارید

ehsan7007
دوشنبه 26 تیر 1391, 16:26 عصر
منظورتون چیه؟
یعنی به تور جداگانه توی یک تایپیک قرار بدم؟

aslan
دوشنبه 26 تیر 1391, 16:35 عصر
نه
منظورم اینه که کدهای اصلاح شده را اینجا بذارین . چون چیزی که تو کدهای بالا میبینیم کدهای قبل از اصلاحتون میباشد

ehsan7007
دوشنبه 26 تیر 1391, 16:51 عصر
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication16
{
public partial class Form1 : Form
{


private System.Windows.Forms.TextBox money;
private System.Windows.Forms.TextBox type;
private System.Windows.Forms.DataGrid DataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;


#region "Variabels"
string nam, famil;
#endregion
#region "FormLoad"



private void Form1_Load(System.Object sender, System.EventArgs e)
{


DataTable dt = new DataTable();

DataBase db = new DataBase();

dt = db.MySelect("select * from DataTable1");
DataGrid1.DataSource = dt;
}
#endregion

public Form1()
{
InitializeComponent();
}


private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"

money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();




#endregion
}
private void save_click(object sender, EventArgs e)
{
#region "Darj dar bank"

DataBase db = new DataBase();
db.DoCommand("insert into DataTable1 values("type.Text + money.Text");

Form1_Load(sender, e);
MessageBox.Show("Inserted");
#endregion

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"

money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();




#endregion

}

private void money_TextChanged(object sender, EventArgs e)
{

}

private void type_TextChanged(object sender, EventArgs e)
{

}

private void database1DataSetBindingSource_CurrentChanged(objec t sender, EventArgs e)
{

}


}
}

aslan
دوشنبه 26 تیر 1391, 17:56 عصر
دستور Insert Into کدهاتون اشتباهه . فعلا اینو اصلاح کنید تا .................
http://www.w3schools.com/sql/sql_insert.asp

ehsan7007
دوشنبه 26 تیر 1391, 18:50 عصر
چطوری باید بشه؟

aslan
دوشنبه 26 تیر 1391, 20:38 عصر
حداقل به این صورت :


db.DoCommand("insert into DataTable1 values('" + type.Text +"','" + money.Text +"'");



البته بهتر است مقادیر را با استفاده از پارامتر ارسال کنید و ...

tooraj_azizi_1035
دوشنبه 26 تیر 1391, 20:48 عصر
به جای این خط:
Form1_Load(sender, e);
بنویس:
Form1_Load(this, e);

ehsan7007
دوشنبه 26 تیر 1391, 22:43 عصر
این کار هم نتیجه ای نداد.
واقعا از دست این جور پیغام ها و ارور ها خسته شدم.

یک عالمه زحمت می کشی،اخرش هم هیچی!!!:افسرده::افسرده::عصبان ی++: