Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am creating a setup of window forms (C#) window application and i used ms access 2003 database i mean (mm.mdb) file .The Problem is when i debug setup then it runs very well without any problem but when i create setup and install it in my pc then database error occured
The error is


Unhandled exception has occured in your application. If you click Continue.the application will ignore this error and attemt to continue.
Operation must use an updateable query


I know this is a Connectionstring path problem

Beacuse when i gave full path of database then setup run very fine But when i change connectionstring . I mean when I use this Path.
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Data\\Mahavir1.mdb;Persist Security Info=True";
Then error occur



Please Help Immedaitely Thanks
Posted
Comments
garaber 7-Mar-13 2:15am    
Run it in debug and cut and past the content of <application.startuppath> so that we can see it's content.
veenusethi 7-Mar-13 2:24am    
i cant understand mr garaber what you said I am sorry Please Explain

Hi Veenu,
When you set up and install the application, your application exe will be at some location say:
C:\Program Files\MyApplication
Now, DataSource=Application.StartupPath + "\\Data\\Mahavir1.mdb;Persist Security Info=True";
means your mdb file should be present in
Data folder which will be a sub folder in folder containing your exe.
Please paste it over there and let me know if you still face the same issue.

There is another solution found here: Link

Thanks.

Kishor
 
Share this answer
 
v2
Comments
veenusethi 7-Mar-13 2:49am    
Yes Sir I place data folder inside bin/debug folder where exe file is exist.But no wins. When i create setup then i make folder data and place mdb file inside data folder. but i dont know why it does not pick path
Kishor Deshpande 7-Mar-13 5:17am    
Can you please post complete exception message along with stack trace so that I can look into it ??
veenusethi 7-Mar-13 6:48am    
Unhandled exception has occured in your application. If you click Continue.the application will ignore this error and attemt to continue.
Operation must use an updateable query
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Data.OleDb.OleDbException (0x80004005): Operation must use an updateable query.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.ExecuteReader()
at mahavir1.patientadd.button3_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
mahavir1
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/mahavir1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.
Kishor Deshpande 7-Mar-13 12:46pm    
Hi Veenu,
Check link: http://www.codeproject.com/Questions/442585/operation-must-use-an-updateable-query-ms-access

For your einform application, you'll have to find out which service is trying to access your file and you'll have to add permission to the folder containing .mdb file for that service.
Check if it works..
veenusethi 8-Mar-13 1:06am    
You mean In program files/ data/mdb file then i should give permissions of r/w to mdb file or give to folder permisiions which is under in program files
Hello ,
In Real Time Situaton,Conection String is there in app.config file.Try To Put the connection string in app.config file.Bcoz , there are situations when client Database is being changed.

Try To Refer the article
get-Connection-String-from-App-Config-in-C#

Hope It Heps You.

Happy Coding :-)
 
Share this answer
 
Comments
helpmcc 21-Jan-19 2:30am    
Nice to assist you. About the c # software suite that connects access

hieplenho2017@ymail.com

You replace the current path of database into (Application.StartupPath)+"\\dbyour.mdb"

good luck

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900