I'm trying to update my database without success. This is how my table looks:
https://i.stack.imgur.com/Q6EDk.png
After opening the modal its look like this:
https://i.stack.imgur.com/JusUp.png
and all the table works with a repeater, this is my code.
protected void Btnupdate_Click(object sender, EventArgs e)
{
try
{
foreach (RepeaterItem RI in rptEdit.Items)
{
Label id = RI.FindControl("Pid") as Label;
TextBox prdname = RI.FindControl("prdname") as TextBox;
TextBox prdprice = RI.FindControl("prdprice") as TextBox;
TextBox prdshortdesc = RI.FindControl("prdshortdesc") as TextBox;
TextBox prdtype = RI.FindControl("prdtype") as TextBox;
TextBox prdbrand = RI.FindControl("prdbrand") as TextBox;
Literal ltl = RI.FindControl("ltlmsg") as Literal;
string ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\Table.accdb";
string SqlString = "UPDATE ProductList SET Pname = ?";
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("Pname", prdname.Text);
conn.Open();
cmd.ExecuteNonQuery();
ltl.Text = "<br/>Done.";
}
}
}
}
catch (OleDbException ex)
{
foreach (RepeaterItem RI in rptEdit.Items)
{
Literal ltl = RI.FindControl("ltlmsg") as Literal;
ltl.Text = ex.Message;
}
}
}
When I click the update button, it's refreshing but nothing happens.
Please help.