远程SQL数据库连接

远程SQL数据库连接

本文介绍了远程SQL数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好日子。我试图通过Windows窗体应用程序连接到远程sqlserver数据库。但唯一的选择我不断得到连接字符串是以下我希望知道它有多安全:



数据源= 190.190.168.100,1433;网络库= DBMSSOCN;初始目录= myDataBase;用户ID = myUsername;密码= myPassword;



代替用户名,我使用点燃的sa帐户我怀疑字符串的安全性。



远程服务器在Windows Server 2012上运行,db是sql2014。





如有任何帮助,我们将不胜感激。



提前付款

弗兰克。



我尝试过:



我使用以下连接在同一个域内运行的字符串运行良好,但在互联网上与其他网络域失败。



数据源= NEPTUNSERVER \ NTSERVER;初始目录= ITEM_MGR ; integrated security = True

Good day to you all. I am trying to connect to a remote sqlserver database through a windows form application. But the only alternative i keep getting the connection string is the following which i wish to know how secure it:

"Data Source=190.190.168.100,1433;Network Library=DBMSSOCN;Initial catalog=myDataBase;User ID=myUsername;Password=myPassword;"

in the place of user name, I used the "sa" account which ignited my doubt about the safety of the string.

The remote server is running on windows server 2012 and the db is sql2014.


Any help with this will be appreciated.

Thanks in advance
Frank.

What I have tried:

I use the following connection string which when running within the same domain works well, but failed with other network domain over the internet.

"Data Source=NEPTUNSERVER\NTSERVER;Initial Catalog=ITEM_MGR; integrated security =True"

推荐答案

 IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = N'yourUserName')
BEGIN
    CREATE LOGIN [yourUserName] WITH PASSWORD=N'yourPassword'
   ,DEFAULT_DATABASE=[yourDataBaseName]
   ,CHECK_EXPIRATION=OFF
   ,CHECK_POLICY=OFF
END


IF NOT EXISTS (
		SELECT *
		FROM dbo.sysusers
		WHERE NAME = N'yourUserName'
			AND uid < 16382
		)
	EXEC sp_grantdbaccess N'yourUserName'	,N'yourUserName'



SELECT 'GRANT SELECT,INSERT,UPDATE,DELETE ON ' + a.table_name + ' TO yourUserName'
FROM (
	SELECT DISTINCT table_name
	FROM information_schema.columns
	WHERE table_name LIKE '%yourSearchToken%'
	) a

-- check, edit the resulting list and execute it


SQLCONNSTR = "Data Source= 192.168.1.1 ;Initial Catalog=DAName;User ID=Test & ";pwd=Test;"





并确保SQL服务器已配置为通过TCPIP接收连接



And make sure SQL server has configure to received the connection over TCPIP



这篇关于远程SQL数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:32