我有一個widnows窗體應用程序,我不能保存數據庫(文本框)中的數據(ms訪問)的數據。存儲的數據可以在應用程序中看到,但是如果我打開數據庫,它不存在...所以如果我打開數據庫並重新啓動表單應用程序,我沒有看到之前插入的數據。無法在數據庫幫助中保存數據!
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();
哇,奇怪。如果原始作者在一定時間內完成編輯,編輯不會顯示爲編輯內容? – aehiilrs 2010-06-18 17:55:16
數據庫文件名中沒有路徑。這意味着數據庫位於當前目錄中。但是當你運行你的程序時,目前的目錄是什麼?在VS中的調試模式下,這是BIN \ DEBUG。更新的數據庫在那裏。 – Steve 2016-09-29 07:47:58