Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run SQL Scripts from C# application across domains

To run sql script files from my C# application, I referred this. http://social.msdn.microsoft.com/Forums/en/adodotnetdataproviders/thread/43e8bc3a-1132-453b-b950-09427e970f31

it works perfectly when my machine and DB server are in the same domain. my problem now is, i'm executing this console application from a machine (name: X, user id: abc, domain D1). the SQL server is in another machine (name: Y, domain: D2). I use VPN to connect to machine Y with user id 'abc' and work on SQL in remote desktop. how can i run sql scripts across domains? I use this in a custom activity in my TFS build template as the last step to run the scripts in the target database which is in domain D2.

i'm getting this error: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

is it possible to connect to the DB using the admin user ID of machine Y in domain D2?

like image 545
Saravanan AR Avatar asked Oct 10 '22 10:10

Saravanan AR


1 Answers

The problem is not the fact that you are on a different domain, this is either a configuration issue on the SQL server on the other end -it may not be configured to allow remote SQL connections and/or SQL server authentication- or you simply can't connect to the server due to some sort of network issue -a firewall being in the middle, for example- Once you figure which one is the problem, you should be able to run the SQL script as described on the post you linked.

like image 140
Icarus Avatar answered Oct 13 '22 11:10

Icarus