通过C#应用程序访问SQL数据库 [英] SQL Database access through C# application

查看:117
本文介绍了通过C#应用程序访问SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!这是我的第一个问题,所以我希望我能做好一切。因为我渴望学习,请随时提供有关如何使用社区网站的反馈。



我即将完成运行不同数据库的应用程序,2客户端计算机中的本地计算机,以及我与Hostgator一起托管的第三个MS SQL数据库。



现在,为了使用SQL Management Studio左右,我需要将我当前使用的IP列入白名单,以便我可以访问。我的问题是,如果必须为需要访问MS SQL应用程序的所有计算机执行此操作,以便它们能够在实际部署应用程序时进行连接。



我被告知我不应该这样做,但我想100%肯定。那将是非常愚蠢的IMO。



提前谢谢



PS。我有一个连接成功的连接字符串,然后我在DataSet中使用它来处理Windows窗体应用程序中的那些。



连接字符串:

Provider = SQLNCLI11;数据源=有效IP;密码= paspas;用户ID = useradmin;初始目录= Database1

Hello everyone! This is my first question ever so I hope I do everything correctly. Please feel free to provide feedback on how to use the community website since I'm eager to learn.

I am about to complete an application that runs different databases, 2 locals within the client computer, and a 3rd one MS SQL Database that I have hosted with Hostgator.

Right now, in order to work with SQL Management Studio or so, I need to whitelist the IP that I am currently using so that I get access. My question is that if this must be done for all the computers that will need to access the MS SQL application in order for them to be able to connect when the application is actually deployed.

I was told that I shouldn't need to, but I want to be 100% sure. That would be pretty stupid IMO.

Thanks in advance

PS. I have a functioning Connection String with successful connections, which then I use in DataSets in order to work with those within the Windows Forms Application.

Connection String:
Provider=SQLNCLI11;Data Source= Valid IP;Password= paspas;User ID=useradmin;Initial Catalog=Database1

推荐答案

如果您正在访问从Windows窗体应用程序系统,然后我会说是(直接询问HostGator的警告)你必须将它们列入白名单。



大多数提供商只允许要从其域访问的数据库。这是因为它们是网站的数据后端。从Windows应用程序中使用它是一种不同的使用方案。



另一种(可能更好的方法)是开发一个与您的数据库交互的Web服务应用程序。通过这种方式,您可以更严格地控​​制数据进出数据库,而不是将权力交给任何获取应用程序的人。 (如上所述的连接字符串,无限制访问是一种很好的破解方式,而且不是很好的方式。)
If you are accessing the system from a Windows Forms application, then I would say yes (with the caveat of asking HostGator directly) you have to white-list them.

Most providers only allow the database to be accessed from its domains. This is because they are meant to be the data back-end to websites. Using it from a Windows application is a different usage scenario.

The alternative (and probably better course) is to develop a Web Service application that interacts with your database. This way you can more tightly control what data goes into and out of your database, rather than put the power in the hands of anybody who gets your application. (Connection strings like the above, with unlimited access is a great way to hack, and not in a good way).


这篇关于通过C#应用程序访问SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆