Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2005, 04:29 PM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 - Update database Problem

First, I got a problem with this line: objContenuRequete.Update(objDataSetUtilisateur, "tblUtilisateur");

I try the solution given there : "http://p2p.wrox.com/topic.asp?TOPIC_ID=31885"

But it didn't work

Second, I was wondering if I can set the update query myself... Would it be alright to do something like dataAdapter = new OleDbDataAdapter("Update ... Where ...", dbConnection);?

objDataTable.Rows[0]["UTIL_MOTDEPASSE"] = strNouvHashMotDePasse;
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(objContenuRequete);
objContenuRequete.UpdateCommand = commandBuilder.GetUpdateCommand();
objContenuRequete.Update(objDataSetUtilisateur, "tblUtilisateur");

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 160: OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(objContenuRequete);
Line 161: objContenuRequete.UpdateCommand = commandBuilder.GetUpdateCommand();
Line 162: objContenuRequete.Update(objDataSetUtilisateur, "tblUtilisateur");
Line 163: return true;
Line 164: }


Source File: C:\Inetpub\wwwroot\intra_ulysse\Charles\test6\Clas seUsager.cs Line: 162

Stack Trace:


[OleDbException (0x80004005): Operation must use an updateable query.]
   System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +1662
   System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) +152
   ASP.Usager.ChangerMotDePasse(String strAncHashMotDePasse, String strNouvHashMotDePasse, String strConfHashMotDePasse) in C:\Inetpub\wwwroot\intra_ulysse\Charles\test6\Clas seUsager.cs:162
   ASP.ChangeMotDePasse_aspx.Page_Load() in C:\Inetpub\wwwroot\intra_ulysse\Charles\test6\Chan geMotDePasse.aspx:30
   System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750



 
Old December 30th, 2005, 03:29 PM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I try something new...

                    objConnectionAccess = new OleDbConnection(strConnecAccess);
                    objConnectionAccess.Open();

                    strSQL = "UPDATE tblUtilisateur SET UTIL_MOTDEPASSE='" + strNouvHashMotDePasse
                            + "' WHERE UTIL_NOMDUTILISATEUR='" + _strNomDUtilisateur
                            + "' AND UTIL_MOTDEPASSE='" + strAncHashMotDePasse + "'";

                    OleDbCommand myCommand = new OleDbCommand(strSQL,objConnectionAccess);
                    myCommand.ExecuteNonQuery();

                    objConnectionAccess.Close();
                    return strSQL;

But it's still give me an error... I Know my sqlQuery is good because I try it directly in access....

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 155:
Line 156: OleDbCommand myCommand = new OleDbCommand(strSQL,objConnectionAccess);
Line 157: myCommand.ExecuteNonQuery();
Line 158:
Line 159: objConnectionAccess.Close();


Source File: C:\Inetpub\wwwroot\intra_ulysse\charles\test6\Clas seUsager.cs Line: 157

Stack Trace:


[OleDbException (0x80004005): Operation must use an updateable query.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr) +41
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174
   System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +92
   System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +65
   System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +66
   ASP.Usager.ChangerMotDePasse(String strAncHashMotDePasse, String strNouvHashMotDePasse, String strConfHashMotDePasse) in C:\Inetpub\wwwroot\intra_ulysse\charles\test6\Clas seUsager.cs:157
   ASP.ChangeMotDePasse_aspx.Page_Load() in C:\Inetpub\wwwroot\intra_ulysse\charles\test6\Chan geMotDePasse.aspx:45
   System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750


There's a weard thing appening when I try to open my db after I run the script... It seem the database open in read only mode...

Any Idea?
 
Old December 30th, 2005, 03:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi chafor,

80004005 error are almost always related to permission problems. Check out this FAQ to learn how to fix the situation:

http://imar.spaanjaars.com/QuickDocId.aspx?QUICKDOC=263

You may need this FAQ to determine the account used by your webserver:

http://imar.spaanjaars.com/QuickDocId.aspx?QUICKDOC=287

HtH and happy New Year,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 30th, 2005, 04:08 PM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'hav already try this... if I used the sample code given with your link it inserted a line without any problem. I really think the problem is because after I run the script the database open in read only mode...

I'll post my two fonctions I use...

    public bool Connection(string strNomDUtilisateur, string strHashMotDePasse)
    {
        string strConnecAccess;
        string strSQL;

        strNomDUtilisateur.Replace("\"","\\\"");

        OleDbConnection objConnectionAccess;
        OleDbDataAdapter objContenuRequete;
        DataSet objDataSetUtilisateur = new DataSet();
        DataTable objDataTable;

        strConnecAccess = "Provider=Microsoft.Jet.OLEDB.4.0; ";
        strConnecAccess += "Data Source="+ @HttpContext.Current.Request.PhysicalApplicationPa th + @"charles\test6\MontrealEnLigne.mdb; ";
        strConnecAccess += "Persist Security Info=False";

        objConnectionAccess = new OleDbConnection(strConnecAccess);

        strSQL = "SELECT * FROM tblUtilisateur " +
                    "WHERE UTIL_NOMDUTILISATEUR='" + strNomDUtilisateur +
                    "' AND UTIL_MOTDEPASSE='" + strHashMotDePasse + "'";
        objContenuRequete = new OleDbDataAdapter(strSQL, objConnectionAccess);
        objContenuRequete.Fill(objDataSetUtilisateur, "tblUtilisateur");

        objDataTable = objDataSetUtilisateur.Tables["tblUtilisateur"];

        if(objDataTable.Rows.Count == 1)
        {
            _strNomDUtilisateur = strNomDUtilisateur;
            _strHashMotDePasse = strHashMotDePasse;
            _strPrenom = objDataTable.Rows[0]["UTIL_PRENOM"].ToString();
            _strNom = objDataTable.Rows[0]["UTIL_NOM"].ToString();
            objConnectionAccess.Close();
            return true;
        }
        else
        {
            _strNomDUtilisateur = null;
            _strHashMotDePasse = null;
            _strPrenom = null;
            _strNom = null;
            objConnectionAccess.Close();
            return false;
        }
    }
    public string ChangerMotDePasse(string strAncHashMotDePasse, string strNouvHashMotDePasse, string strConfHashMotDePasse)
    {
        string strSQL;
        string strConnecAccess;

        OleDbConnection objConnectionAccess;
        OleDbDataAdapter objContenuRequete;
        DataSet objDataSetUtilisateur = new DataSet();
        DataTable objDataTable;

        strConnecAccess = "Provider=Microsoft.Jet.OLEDB.4.0; ";
        strConnecAccess += "Data Source="+ @HttpContext.Current.Request.PhysicalApplicationPa th + @"charles\test6\MontrealEnLigne.mdb;User Id=admin;Password=;";

        objConnectionAccess = new OleDbConnection(strConnecAccess);

        if(_strNomDUtilisateur != null)
        {
            if(strNouvHashMotDePasse == strConfHashMotDePasse)
            {
                if(strAncHashMotDePasse == _strHashMotDePasse)
                {
                    objConnectionAccess = new OleDbConnection(strConnecAccess);
                    objConnectionAccess.Open();

                    strSQL = "UPDATE tblUtilisateur SET UTIL_MOTDEPASSE='" + strNouvHashMotDePasse
                            + "' WHERE UTIL_NOMDUTILISATEUR='" + _strNomDUtilisateur
                            + "' AND UTIL_MOTDEPASSE='" + strAncHashMotDePasse + "'";

                    OleDbCommand myCommand = new OleDbCommand(strSQL,objConnectionAccess);
                    myCommand.ExecuteNonQuery();

                    objConnectionAccess.Close();
                    return strSQL;
                }
            }
        }
        return "abc";
    }

 
Old December 30th, 2005, 05:20 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you get when you dump the contents of the variable strConnecAccess to a Label or TextBox??

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 5th, 2006, 11:18 AM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\goodpath\charles\test6\MontrealEnLigne.m db;User Id=admin;Password=;

 
Old January 5th, 2006, 04:52 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is that the correct path to the database you're using?

And did you add the right account to the test6 folder and give it write permissions? What account did you add??

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 6th, 2006, 12:23 PM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes to both question..., but now I'm sure the problem is with IIS because when I try it on my machine... (I was on our intranet before) It's work...

Thanks for you're help Imar.

Chafor






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15 - Update sql db problem oneflatfoot BOOK: Beginning ASP 3.0 1 November 19th, 2006 06:20 PM
Problem with update database in datagrid annie_stwg ASP.NET 1.0 and 1.1 Basics 4 April 1st, 2006 12:10 AM
Database Insert/Update problem with VB.NET form tino mclaren VB Databases Basics 2 February 4th, 2005 05:12 AM
Another Chapter 17 problem (DataGrid Update) bolibompa BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 May 11th, 2004 12:32 PM
chapter 14 Try It Out problem - update Jams30 BOOK: Beginning ASP 3.0 1 March 22nd, 2004 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.