I'm trying to open another form with a button and it's only ok at the beginning. After a few forms made the stackoverflow error acours ! The error is on form 1, form 2 and form 3 (I started to debug multiple times): the codes are really simple. like for form 3:
public partial class Form2 : Form
{
Form3 obrok = new Form3();
public Form2()
{
InitializeComponent();
}
public void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
obrok.Show();
this.Hide();
}
}
(added from the comment, especially to preserve code indentation (MI))
The above error is solved(using statement) Now the problem is when i wan't to save values from textbox to the access database. The code: Form1 users=new Form1(); private void button1_Click(object sender, EventArgs e) { string conString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\Users\Simon\Desktop\save.mdb";
OleDbConnection empConnection = new OleDbConnection(conString);
string insertStatement = "INSERT INTO obroki_save "
+ "([ID_uporabnika],[datum],[ID_zivila],[skupaj_kalorij]) "
+ "VALUES (@ID_uporabnika,@datum,@ID_zivila,@skupaj_kalorij)";
OleDbCommand insertCommand = new OleDbCommand(insertStatement, empConnection);
insertCommand.Parameters.Add("@ID_uporabnika", OleDbType.Char).Value = users.iDTextBox.Text;
insertCommand.Parameters.Add("@datum", OleDbType.Char).Value = DateTime.Now;
insertCommand.Parameters.Add("@ID_zivila", OleDbType.Char).Value = iDTextBox.Text;
insertCommand.Parameters.Add("@skupaj_kalorij", OleDbType.Char).Value = textBox1.Text;
empConnection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
empConnection.Close();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
}
}
}
When i wan't to pass the values it show a massage that there is an error in the data type in conditional expression .