Click here to Skip to main content
13,901,946 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
how to make sql winform application to be accessible by other user in LAN when they don't have SQL adapter or executor

What I have tried:

i am using visual studio C# and SQL
Posted
Updated 27-Nov-18 20:21pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This is going to be a pretty high level answer.

You need to not think of SQL as a dependency that gets deployed as part of your application, that is likely a poor design but i don't know a thing about what you are attempting to do.

The route you should go is install sql server itself on a dedicated box, then give your application access to that sql server by connecting to it with ado.net or entity framework (or any other of the millions of DB connectivity options). There are other options to this to, like creating a restful API and exposing the API to your app and having your winforms app simply consume the API and not having to worry about a ton of different client machines having connectivity to the sql server itself.

Either way you go, this will eliminate you having to install DB connectivity dependencies on each of the client machines that will be running your winforms app.

I'd recommend a good google search as the first place to start.

connect to sql server from winforms - Google Search[^]

First result looks promising

.net - Connecting to SQL Server Database C#-WinForms - Stack Overflow[^]

If you get started on this and get stuck, feel free to come back with a clear explanation of your issue, relevant code samples and a description of what you've tried to resolve your issue and I am sure you will find meaningful help.
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

A question for question, do you trust everybody on the LAN? Or, are they just allowed to read the information and not do other stuff? One simple way to do is, provide a report-like interface to the users and ask them to enter their own credentials—the user accounts that are created inside the database—and manage what areas do they have access to. Several database engines provide this, and yet this is so far the simplest way to do this with only the database engine.

Yet another way to do this would be to write a web interface, like ASP.NET based Web API (since you are talking about WinForms), where they can consume the backend services for the database. The main features that a web interface would provide would be,

  1. Quick and easy access via any web browser.
  2. Manage who can access the resources, and caching, cookies, and JWT can be applied easily.
  3. Nobody has direct access to the database—most important one!

In the database, the major issue is, and especially those databases that are accessible on the network, that anybody can access the tables directly. Which is the worst way of providing the services that are depending on the database. Just imagine, what a person can execute on the database. I will leave you with that.

Although you can argue, that a temporary table can be generated, or a read-only table can be generated. But trust me, a web interface is an easy way of doing things. If I had to develop this kind of a system, I would be investing my time and effort in a good web front-end, that abstracts away the direct access to a database, and uses a read-only user account (can be controlled via a connection string) for non-admin users, and an admin or write-access provided account for the admins only. This can easily protect you from SQL Injection, in case you do write a bad query, since users won't have a write access at all.

Although this seems like a big thing, what I said, in a nutshell is, create separate accounts with read, or read-write access, then use those accounts for each individual user to access the resources from backend.

ASP.NET Web API | The ASP.NET Site[^]
   
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190306.1 | Last Updated 28 Nov 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100