views:

77

answers:

1

I have an widnows form aplication and i can't save the data from aplication(textboxes) in the database (ms access). The stored data is seen in the aplication, but if i open the database it's not there... so if i open the database and restart the form aplication i don't see the before inserted data .

 string conString = "Provider=Microsoft.Jet.OLEDB.4.0;"
         + " Data Source=save.mdb";


            OleDbConnection empConnection = new OleDbConnection(conString);


            string insertStatement = "INSERT INTO zivila "
                                 + "([naziv]) "
                                 + "VALUES (@naziv)";

            OleDbCommand insertCommand = new OleDbCommand(insertStatement, empConnection);

            insertCommand.Parameters.Add("@naziv", OleDbType.Char).Value = textBox1.Text;

            try
            {
                empConnection.Open();
                int count = insertCommand.ExecuteNonQuery();
                empConnection.Close();
            }
            catch (OleDbException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {

                textBox1.Clear();
+3  A: 

I think you're missing a square bracket ]

Seattle Leonard
i cut some coude out so... the compiler doesn't show any errors
Simon
@Simon The compiler wouldn't show any errors. It's a problem with the SQL. Although you'd think that it'd have thrown an exception on execution...
lc
I said that the data i use is useable OK? So if i wouldn't have a bracket i would get an error before the data would be saved. I edited the question(added the ] so please leave that bracket alone.It was my mistake editing the code cous i didn't want' to put the whole code on cous it's not needed. I would just like to know why doesn't it(the data) save to my database. If i use the whole path as the datasource then the data is stored but i have to restart the aplication to make it useable and i would have to change the path of the datasource everytime i would move the aplication...
Simon