Some systems wants connection string from you. Whent you give connection string to them they just tell you "ERROR!" or "No connection!". It is not helpful. What went wrong?
Sometimes I test connection strings with powershell. Write this kind of script with notepad or similar editor:
$connectionString = 'Data Source=123.123.123.123,1234;database=NameOfYourDatabase;User ID=migtyuser;Password=secret123!' -f $ServerName,$DatabaseName,$userName,$password
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $connectionString
$sqlConnection.Open()
$sqlConnection.Close()
Save it as connectiontest.ps1.
123.123.123.123 is IP number of your server and 1234 is the port number (not mandatory). Save your file as Powershell file.
Then start Windows powershell as admin user and give next kind of commands:
>set-executionpolicy remotesigned
- Answer Y-when system asks permission.
Okay. Now we can use connection tester. Give powershell command:
> ./connectiontest.ps1
If everything is just ok. Nothing happens. Hurray! But if there is something wrong with your connection string Powershell will give nicely detailed error message. It is much better error message than with most other systems.
No comments:
Post a Comment