locked
can not connect to SQL server in a VPN via local machine RRS feed

  • Question

  • User1182587605 posted

    Hi 

    I am working on a my local machine with VS, C#. I am able to connect to my client VPN but if I try to connect from a connection string in my web.config file I am unable to access the same SQL server. Please guide me how to solve this issue. 

    My connection string is:

    <add name="ApplicationServices" connectionString="DataSource=101.232.122.1;Password=******;User id=sa;database=Sample_APPLN;server=Dev_Env;" />

     The values are not actual. Please tell me what I can do get things right.

    I have provided my client system IP address as Data source, Database name, User name and Password(SQL authentication) in my connection string. Should I check the port or something or is it a SQL server administration issue.I don't have much experience on SQL Admin. Please guide me the steps to solve this problem. I need to get this working tomorrow.

    Please do the needful. 

    Regards,

    Deepak

    Wednesday, October 19, 2016 3:58 PM

Answers

  • User-2057865890 posted

    Hi Deepak,

    The following example is for a SQL Server database using SQL Server security (log on to the server by using user credentials in the connection string).

    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;
    Password=password;MultipleActiveResultSets=True" />

    https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx 

    Should I check the port or something or is it a SQL server administration issue

    Connect via an IP address

    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=xxx.xxx.xxx.xxx,xxxx;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;
    Password=password;MultipleActiveResultSets=True" />

    If it is a SQL server administration issue, you could refer the following article.

    • Allow remote connections to this server
    • Make sure that TCP/IP is enabled
    • Configure your firewall settings

    https://blogs.msdn.microsoft.com/walzenbach/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008/ 

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 20, 2016 7:15 AM

All replies

  • User753101303 posted

    Hi,

    acmedeepak

    I am unable to access the same SQL server.

    It is always best to tell what happens (exact error message or the best English translation you can) rather than just that "it doesn't work".  For example here "DataSource" seems wrong to me (it would be "Data Source" and "Data Source" and "Server" are the same thing).

    Knowing which error you have would liekly help to confirm if your connection string is wrong or if it is correct (maybe a typo in your post) and if instead you can't reach the db server. And again you would have another error if the db doesn't exists or if the user is not allowed to access the db etc...

    So please never post again about an error without telling which error you have.

    Not direcly related but using sa is likely a bad idea (this is an administrative account that can do all tasks on the server including dropping a db, usually you try to use for your app an account that has just the needed rights). Plus if sa user is changing his password for a safety reason, your app won't access any more etc...

    So for now try perhaps :

    Data Source=101.232.122.1;Password=******;User id=sa;database=Sample_APPLN

    (added a blank Inside DataSource, removed the Server entry which is the same than Data Source).

    Wednesday, October 19, 2016 4:17 PM
  • User-2057865890 posted

    Hi Deepak,

    The following example is for a SQL Server database using SQL Server security (log on to the server by using user credentials in the connection string).

    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;
    Password=password;MultipleActiveResultSets=True" />

    https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx 

    Should I check the port or something or is it a SQL server administration issue

    Connect via an IP address

    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=xxx.xxx.xxx.xxx,xxxx;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;
    Password=password;MultipleActiveResultSets=True" />

    If it is a SQL server administration issue, you could refer the following article.

    • Allow remote connections to this server
    • Make sure that TCP/IP is enabled
    • Configure your firewall settings

    https://blogs.msdn.microsoft.com/walzenbach/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008/ 

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 20, 2016 7:15 AM