Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net insert command access database

Posted on 2007-10-10
15
Medium Priority
?
394 Views
Last Modified: 2013-11-07
help me pleasei Have one ASP.NET (access data mdb)  INSERT problem.
its working on my local computer but when i have uploaded it on my webserver
my connection sting isnt working

MY CONNECTION STRING IS AS FOLLOWS
=================================
        OleDbConnection dbcon2= new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connection string"].ConnectionString);
        LblEmail.Text = TxtEmail.Text + ", Thankyou for Joining.";
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = dbcon2;
        cmd.CommandText = " insert into mailid(emails) values(@email)";
        cmd.Parameters.Add("@email", OleDbType.VarChar, 50).Value = Txt2mail.Text.Trim();
        cmd.Connection.Open();
        cmd.ExecuteNonQuery();
        cmd.Connection.Close();
        Response.Redirect("default.aspx");


ERROR ENCOUNTERED IS AS FOLLOWS
================================

Server Error in '/' 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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[OleDbException (0x80004005): Operation must use an updateable query.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
   Join.BtnSubmit_Click(Object sender, EventArgs e) +247
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

 
please help me what to do in this case
0
Comment
Question by:dontnetsanjay
15 Comments
 
LVL 14

Expert Comment

by:Jai S
ID: 20047533
can you check in your webconfig file whether the ACCESS database is in the specified locatiuon;....

one option would be to create a ODBC connection for your access database and then use that DSN name to connect to the database rather than sopecifying the DB name explicityly...thts a best practise
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 20047535
Have you changed the connection string properly in web.config file ?

s this is problem for all pages where using the connection string?
0
 
LVL 15

Expert Comment

by:crisco96
ID: 20047566
Change your code to the following:

        OleDbConnection dbcon2= new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connection string"].ConnectionString);
        LblEmail.Text = TxtEmail.Text + ", Thankyou for Joining.";
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = dbcon2;
        cmd.CommandText = " insert into mailid(emails) values(?)";
        cmd.Parameters.Add("@email", OleDbType.VarChar, 50);
        cmd.Parameters["@email"].Value = Txt2mail.Text.Trim();
        cmd.Connection.Open();
        cmd.ExecuteNonQuery();
        cmd.Connection.Close();
        Response.Redirect("default.aspx");

I think with oledb commands you have to specify parameters in the command text with ?'s, then the order you add them to the parameter collection is the order they are used in the command, the names really don't matter.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dontnetsanjay
ID: 20047685
I will check this question mark,

I will recheck path and file name
otherwise it is working perfectly on my local webserver
0
 

Expert Comment

by:muthan_vinoth
ID: 20047744
The problem is you access database does not have enough rights. give enough permissions for IUSR and ASP.net in security tab at property sheet of both mdb and folder that contains mdb
0
 

Author Comment

by:dontnetsanjay
ID: 20047772
hello Muthan,

i have only a small space with this server
so i do not have any proviledge to asign permission on webserver

there fore i will request them to do so

even though i have mentioned my problem to them but not yet received any support

thanks
0
 

Expert Comment

by:muthan_vinoth
ID: 20047841
Hi Sanjay

There are no problems with your connection strings.

Please have a look  for more information
-http://forums.asp.net/p/154273/1944044.aspx

If your server is an UNIX one then use FTP Client such as FileZilla and Change file and directory mode to 777.

0
 

Author Comment

by:dontnetsanjay
ID: 20047876
i get u muthan
my sever (what i am told and i have paid is win server)
and it shows filemmodes  that is attrubutes -rw-rw-rw-
now what attributes should i use here

?
0
 

Author Comment

by:dontnetsanjay
ID: 20047894
yes mdb file attibutre is -rw-rw-rw-
and daabase attribute drw-rw-rw-
this for all other folders too
0
 

Author Comment

by:dontnetsanjay
ID: 20048017
Even Question mark does makeany change

hey I am using this statement in web.comfig file is it wrong?

        -->
            <authentication mode="Windows"/>
            <!--
0
 

Accepted Solution

by:
muthan_vinoth earned 1500 total points
ID: 20048032
1.       if you have FTP access , Open your FTP Using IExplore
2.      Expand the folder tree to the location of your Web site database file.
3.      Right-click Your_Web_Site_Database_Name.mdb, and then click Properties.
4.      Click the Security tab, and then click Add.
5.      In the Enter the object names to select box, type IIS_WPG, and then click OK.
6.      In the Group or user names list, click IIS_WPG.
7.      In the Permissions for IIS_WPG list, click to select the Allow check box that is next to Write.
8.      Click Add.
9.      In the Enter the object names to select box, type Network Service, and then click OK.
10.      In the Group or user names list, click Network Service.
11.      In the Permissions for Network Service list, click to select the Allow check box that is next to Write.
12.      Click Apply, and then click OK.

These steps apply for
machine\ASPNET, IIS_GPM, IUSR_machine, IWAM_machine, and everything else is IIS_GPM group
0
 

Author Comment

by:dontnetsanjay
ID: 20048072
how do we open ftp using explorer?
i am using FTP commander
i have tried using ftp://www,site name login box appears but it does not allow login even though I am entering right username and password it says could not login with username and pASSWORD SUPPPLIED
0
 

Author Comment

by:dontnetsanjay
ID: 20048092
hey okay but when i click onproperties it says it does not suport changing file permission
0
 

Author Comment

by:dontnetsanjay
ID: 20084984
Hello muthan,
Yes problem was with file access,

persmissin has been provided by my web host for the same.
icould not have done this at my end
thanks anywa ur answer made me argue with them for file access permission earlier they also said that check your connection string but yeah u were right again there was no problem with connection string

can u please also direct some link were ican get these kinda information whcih one needs to knw while hosting asp.net site

thanks oncce again
0
 

Expert Comment

by:muthan_vinoth
ID: 20087248
www.google.com this is not a joke.. reach me muthan_vinoth@yahoo.co.in
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question