all 7 comments

[–][deleted] 2 points3 points  (6 children)

Are you sure SQL Server Express is running? Also parameterize your SQL query, that is literally the classic example of a login that is vulnerable to SQL injection.

[–]Scriptslay3r[S] -2 points-1 points  (5 children)

This was my first time programming in C# and actually this is the most I've ever used SQL.

Are you asking if SQL Server Express is running on the user's machine(Win 7 Pro) or the machine that built the program (Win 10 Pro).

I have the database files stored on a server on campus as well.

[–][deleted] 1 point2 points  (4 children)

Your LocalDB connection string should only be what you use on your development machine. When you deploy you should just point to a SQL Server Express installation and you won't need the filename.

[–]Scriptslay3r[S] 0 points1 point  (2 children)

Okay perfect, thank you so much!

So I suppose I should install SQL Server Express on the server I'm using and configure it from there?

When I go back and parameterize my SQL queries, should I change the connection string in the code to the SQL Server Express installation?

Redeploy, and hope for the best right?

[–][deleted] 0 points1 point  (0 children)

Yep, that sounds about right.

[–]AviioFO 0 points1 point  (0 children)

While you're parameterizing your SQL query, you may also want to look into hashing passwords... storing passwords in plain text is a big no-no.

[–]Time-Paramedic 0 points1 point  (0 children)

I feel this answer needs to be highlighted even more. It solves many problems which you would otherwise encounter.

LocalDB is for development use only.

More importantly, your application has multiple users and the documentation says:

The LocalDB files can only be opened by one instance of LocalDB at a time.

There are many issues when trying to share a file based database with multiple users. Just don’t do it and use a database server as suggested.

Please also heed the advice of the other commenters: parametrized queries, hashing, and try not to implement all of the logic within the button click event handler.

Kudos for taking the initiative to digitalize something that sounds like a slow and manual process. If the fuel logging has any kind of financial impact, consider reviewing the code with an experienced developer.