#Winform app(.NET Core) not working in client side

37 messages · Page 1 of 1 (latest)

undone kestrel
#

hello Everyone, Hope you all doing well.
i have a problem that keeps me from finishing any C# project i do and its not showing in my Development Desktop PC (The App on my PC works Fine) the moment i use a Setup project to build it and test it on my other laptop it start throwing SQL errors or not showing any errors at all just like if i did not run the app at all.
Example App:
a simple Password Vault to store my emails and passwords with a Login.
Database: SQLite
the App on my PC works fine in debug and release and when i build it with setup project and run it from my other laptop i get an error like
(" Attempt to write a Read only Database ") and it stops. also before this error was another one (" SQL logic error AdminTable was not found " ).

Please can someone Explain Or Help me Build The App Properly because i spent the last 5 days Scratching my head with no Progress seen.

  • if any details required i can Provide it later.
    Thank you All in Advance.
wild ruin
#

first of all ensure that the SQLite database file is writable on the target laptop.

#

second verify that the database file exists on the target laptop.

#

and it can be another problem. we may discuss it further. DM

hard salmonBOT
#
Direct Messages

Please keep discussion on the server. It helps you get responses more quickly from more people & with more viewpoints. It also helps protect you from scammers.

We recommend disabling DM's from all public servers.

modest comet
#

It much more beneficial to help in help channels as others may be able to assist. Also other member who may be having similar issues may find it useful

undone kestrel
#

yes it seems my issue is database cant open or read only. i am using DB Browser for SQLite to create the database and i was sure to run it as administrator and even Visual studio 2022 is running as admin.

#

before as i told you i run the program and nothing shows or happen so i thought to wrap the starting statement of the ( program.cs ) in the solution explorer with a try and catch method and it did show me the error message (unable to open database file)

#

i should point out that i am using an absulote Path for my Database :
Example of the Path
SQLiteConnection conn = new SQLiteConnection("Data Source=E:\Program Files (x86)\projects\Project_Management_System_Solution\Project_Management_System\MainDB.db");

undone kestrel
#

i will type the most important points regarding database and you might see what i am doing wrong.
1- database file is included in the Project Solution and in the Debug Folder.
2- database Properties (Build Action is marked as Content and Copy to Output Directory is marked Copy if Newer).
3- Using a Setup Project i included the Publish output and Content output.
4- i also included the database in the output as a file and made sure the ReadOnly option is marked False.

wild ruin
#

Regarding your database path, I noticed that you are using an absolute path for your database file, which can cause issues when running the application on a different laptop. Instead, you should use a relative path to ensure that the application can find the database file regardless of the location of the executable.

#

if error occurs again, let me know.

undone kestrel
#

i tried and let the Path relative and the error still shows

#

i have two erros i can see now and both database related

#

if path is Absolute the error is (" cant open database ") which makes sense as the program cant find the database to open it in the Client PC.

#

if i make the Path relative i get the error (" attempt to write a readonly database ") which means i see the database but cant write to it

#

could it be the error is caused by the DB browser for SQLite and its something i cant control ?

wild ruin
#

I recommend that you ensure that the database file has read-write permissions on the target laptop. You can do this by right-clicking the database file, selecting Properties, and then setting the "Read-only" attribute to "No."

undone kestrel
#

true

#

i did that and made Readonly property to False

#

still same error

#

i honestly started to think i am running out of possible fixes to this

#

most logical things has been set correctly i presume

wild ruin
#

think about SQLite library. I think that is problem.

undone kestrel
#

you mean the System.Data.SQLite Package we download from NUget Package ?

#

you might be right actually

#

i will try with System.Data.SQLite.Core version

#

and update you here

undone kestrel
#

Great News !!

#

after searching the internet i found an article about custom actions that execute after the installing of the Program this custom action would give the user permissions to write to database.

#

i tried that but failed because i did not know how honestly

#

what fixed the issue for me was just me asking my self if it has to do with permission what would happen if i change installing directory so i made a folder on Desktop and install it there

#

and it worked like a charm.

#

Summary:
if you face the Error " Attempt to Write a Read-Only Database " one solution is to change where to install the App Because C:\ is System Protected. so install it on a Folder you make on Desktop and take it from there

#

PS: Database is SQLite and it was made with DB Browser for SQLite.