Execute queries on SQL Server without having account [closed] - c#

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Does anyone know is there a way for an application (that's connected to SQL Server) to make SQL queries to a database, but restricts the user from accessing directly to the database using SQL Server Management Studio?
Sorry, I know this sounds very confusing, but the reason I'm asking this is because at work, I'm using an application that allows me to enter data and upload it to the database. I assume a predefined INSERT sql script were loaded into the application, but when I log in to SQL Server Management Studio it won't let me use the INSERT statement at all. I was wondering why and how a application like this can programmed??
Any info or insight on this will be greatly appreciated.
Thanks

Since you are able to access the database via SSMS without an error, the account can obviously access the database. However, permissions will be limited to those granted to the account, either directly or via role membership.
It is likely the application is using a stored procedures to insert data if you are using the same account and your ad-hoc INSERT fails with an access is denied error. When a stored procedure is used for data access, the invoking account needs execute permissions on the stored procedure but not the underlying tables. Permissions on indirectly referenced objects are not evaluated as long as the ownership chain is unbroken.
See https://technet.microsoft.com/en-us/library/ms188676%28v=sql.105%29.aspx for a more complete description of ownership chains.

Related

how can I save and load information in a desktop inventory application C#? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Im developing this desktop app for study reasons
but im using SQL Server for database management so reading around the web i find some articles on this and why it is bad practice, i cannot move my entire project to another PC without installing SQL Server. then i find this:
Save and load inventory
So i don't know what method of saving and loading information I need for this project, I think in SQL Lite or maybe I can use a simple file to save all the information like the mentioned post.
Im using a DB with relationships and i dont know if i can made it with a data persistence file. What should I do? what is the best practice?
PD: Sorry for my bad english
Usually your SQL Server would be hosted on a remote computer when used outside development, but it depends on exactly what your application is supposed to do.
If it's a requirement for you to be able to switch computers, and not host your database on a remote server, I'd say using SQLite is a good choice.
Alternatively, you could have 1 big file that has all your data instead of a relational database, although I wouldn't really recommend it. It's good for quick prototyping of things, but all your data would be denormalized, which can end up being more effort to work with than SQL. This is what the inventory example you linked does.
If you are planing to move your application on different computers and don't want to install any database management system there then SQLite is the best option.
All of your data will be stored in one file and you can freely move your application an other PC without installing any database management system there.
Here is good article explaining that in which scenarios SQLite is good choice.

How does odbc allow more than one session to access and modify the database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm working on an asp.net web site application that uses ODBC to store data into a 2008 R2 Microsoft SQL Server.
My understanding of ODBC is that it is an open database connection, where the connection to the database can be kept open, and during this time only "one connection" can modify, update, insert into the database. Until that connection is closed and another one is opened.
The application is designed to allow multiple user sessions to open connections to the database at the same time, and I don't see any client code that is handling concurrency issues regarding insertions or modifications to the database.
How are multiple users in separate sessions (for example, three users on three separate web browsers), able to modify, update, and insert information safely into one database; particularly when all three users are modifying, deleting, or inserting into the same row at the same time. Does the database automatically provide a lock and wait for that lock to free up from one user session to the next to resolve this concurrent data access issue?
You cannot modify the same row on the same table at the same time as someone else. This is inherent in the ODBC connection statement. For instance, UserA is updating Table1 on and UserB is also trying to perform updates on Table1, if there are rows in common between the two users, the ODBC will throw an error with feedback about the data currently being locked or something similiar (depending on how you're accessing the ODBC).
Regardless of Optimistic or Pessimistic style of ODBC record locks, only one user can make modifications to the same data at the same time.
However, multiple users can make changes to the same Table if no conflicts occur in the modifications taking place in certain circumstances (this would be a difference in locking types).
FYI - This is not really a coding question.
Each connection is isolated. You could have 1000s of connection.
A web server acts on the benefit of many http connections so you don't need a lot.
It is possible to share a connection across threads but it is not a good practice. You could get the response from another session.
The database manages isolation with locks. Only one person can have an update lock at a time.

SQL Databases on more than one computer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm writing a desktop program that allows you to view customer information, as well as adding, removing, editing etc. It's to be installed onto a friends computer. The database will be stored locally on one computer. Only one user will be able to access the database via the desktop application.
If I were to publish it, and attempt to run it on another computer, would it work? Or would that computer also need SQL Server on it?
I assume you are talking about a desktop application. If this is so, you can provide your application to someone else and have them use it. However, there are different points that you need to consider:
Where will the your code reside?
Where will the database reside? Is there 1 shared copy or will each user has his own? This has a major effect on the ease of installation and the cost of your application.
If the database is shared, do you have a Server to host the database where all users will logon to?
Does the database have a max. number of users (limit/meter)?
Will the database be behind a firewall?
How many copies of the database need to be purchased?
It depends.
If you just use the most basic database connection options then either the other machine will need to have sql installed, or the other machine will need to have network access to the database running on your server.
If your application is intended for a corporate intranet having a single DB server running on the network is probably an acceptable solution. For anything else it probably isn't.
If your users need to share data I'd recommend hosting the data on a server yourself and exposing it to the end user as a web service instead of a raw database connection.
If your users don't need to share data, look into compact databases intended to be embedded in applications. Since you're using C# I'd recommend SQL Server Compact because it speaks the same flavor of SQL as Microsoft's larger database products. The other major player in this space is SQLite; which is dominant outside of the Microsoft stack.

Accessing MDF file thread safety [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is MDF file access (when attached to SQLEXPRESS) thread safe?
I have a local MDF file deployed along with my WPF client application.
I'm using the MDF file to persist some client-specific settings. There may be many threads SELECTing and UPDATEing the same rows at the same time and thus accessing the file via the SQL connection provider simultanously.
Now, what i'm asking is wether or not I can treat the thread syncronization the same way as I do with remote SQL SERVER databases (just leave all the work to the SQL connection provider) or do I have to wrap my DB calls inside a critical section?
Thanks!
I'm really confused, it's a Microsoft SQL database running on a database server that manages table and row locking and conflicts as long as you use optimistic concurrency in your WHERE clauses when updating rows. For example
update settings set A = 'val' where A = 'old val'
so of course it's thread safe.
MDF file is Main Database File.
You can't write to MDF file directly(theoretically),you are accessing through SQL Server engines and clients.
As for multiple SELECT and UPDATE you are relay on database transaction isolation levels(read commited,read uncommited,serializable,snapshots).
Isolation Levels in the Database Engine

Extending application to use on LAN [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am not a very experienced programmer. And I am facing technical issues in database servers.
I have developed a small standalone C# Application which is already in use.
It uses SQLite database. The database usage is not very heavy. Only a few form needs to be read and write to the database.
Now there is a requirement that it should be used on LAN.
I know that SQLite is not a good database option for client/server.
But keeping these points in mind should I change the database or not..
The application is already using SQLite and this is not a project from start.
The database usage is not very heavy. Only a few forms will be filled and data is written on the database.
At most 1-4 Pc's will be using the application simultaneously.
I had tried to install MS SQL server on my customers PC but then I am facing so many technical issues and it is taking a lot of time.
So I am thinking to stick with SQLite only.
Any suggestions will be greatly appreciated.
So is your question "Can I share a SQLite database between multiple workstations", or "How to install SQL Server"?
I'd say go with the last. SQLite even promotes the use of a client-server DMBS if you require multiple processes accessing the same database.
Installing MS SQL server can be pain; you have to ensure .NET framework is installed, windows service pack is installed and MSI has correct version. Still I would prefer going that way, because of robustness and reliability it promotes and rather write some robust installer to "make it happen".
You can of course, keep your current solution and write web service that will lock access to database to one-client & one-query at time only and rewrite your app to use this service instead of accessing db directly.
Btw. - Microsoft SQL Server Compact Edition is working similar to SQLLite (in the terms ease of install), and it allows multiple connection to the same database (.sdf file)
http://technet.microsoft.com/en-us/library/bb380177%28SQL.90%29.aspx

Categories