Hi,
I'm using ASP.net c#, visual studio 2005, and access 2003. I'm trying to add a record to a database with the info of a textbox when that textbox changes. so I wrote this code in the Textchanged method
protected void _TextChanged(object sender, EventArgs e)
{
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AccessDB\db1.mdb;User Id=admin;Password=;");
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "insert into comments (comment) VALUES (?)";
cmd.Parameters.AddWithValue("comment", COMMENT_BOX.Text.ToString());
cmd.Connection = cn;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
cmd.Dispose();
cn.Dispose();
COMMENT_BOX.Text = String.Empty;
}
The text box look like this:
<asp:TextBox ID="COMMENT_BOX" Name="COMMENT_BOX" runat="server" Enabled="true" OnTextChanged="_TextChanged" Height="24px" Width="344px" /> Comments
But this doesn't work, I even tryed to refresh the page after the text changes but no luck..
Anything i'm missing here?