0

I have draw to text boxes and a button on default.aspx page and write these lines on button click event for submit my data but it gives an error message "Operation must use an updateable query" follow the link on line "cmdPerson.ExecuteNonQuery();"..............

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        //string source = ConfigurationManager.AppSettings["ConnectionString"].ToString();
        OleDbConnection cnnPerson = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("~/Database/Login.mdb"));
        try
        {
            string strStatement = "INSERT INTO Login(Log_Name,PasswordName) VALUES('" + First_Name.Text + "', '" + Last_Name.Text + "');";
            OleDbCommand cmdPerson = new OleDbCommand(strStatement, cnnPerson);
            cnnPerson.Open();
            cmdPerson.ExecuteNonQuery();

            First_Name.Text = "";
            Last_Name.Text = "";
            First_Name.Focus();
        }
        finally
        {
            cnnPerson.Close();
        }
        Response.Write("Data Inserted Successfully !!!!"); 

    }
}

Please tell me the suggestion for this problem ...............................

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by dickersonka
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.