TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kishore_reddy_m
NA
1
0
webapplication using ADO.NET,C Sharp,OleDb,Ms Access,ASP.NET
Feb 15 2005 12:28 AM
Hai,I found this website very useful.I have seen people giving good suggestions regarding programming practices.Hoping to find some help i am posing this .Kindly help me The follwoing program uses CSharp,ado.net,oledb and msaccess database.The program is getting compiled but an error is generated while trying to execute the project. The pgm is WebForm1.aspx.cs.it accesses an MSaccess database called custom.mdb. the custom.mdb has only one table called "Customers".I tried to insert the following two vales into the "Customers" table.but an unhandled exception occurs. !!!Please Help Me!!!! I am using .net IDE using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb; namespace custom { ///
/// Summary description for WebForm1. ///
public class WebForm1 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here OleDbConnection conAuthors; string strInsert; OleDbCommand cmdInsert; conAuthors = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=c:\\custom.mdb" ); strInsert = "Insert Into Customers Values ('abc', 'eddy' )"; cmdInsert = new OleDbCommand( strInsert, conAuthors ); conAuthors.Open(); cmdInsert.ExecuteNonQuery(); conAuthors.Close(); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } ///
/// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///
private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } The following Error is generated!!!!!!!!! in the html output Server Error in '/custom' Application. -------------------------------------------------------------------------------- Operation must use an updateable query. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query. Source Error: Line 27: cmdInsert = new OleDbCommand( strInsert, conAuthors ); Line 28: conAuthors.Open(); Line 29: cmdInsert.ExecuteNonQuery(); Line 30: conAuthors.Close(); Line 31: Source File: c:\inetpub\wwwroot\custom\webform1.aspx.cs Line: 29 Stack Trace: [OleDbException (0x80004005): Operation must use an updateable query.] System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +67 custom.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\custom\webform1.aspx.cs:29 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +731 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Reply
Answers (
1
)
DataReader and ODBC, help please...
Accessing SQL table attributes using datatable