.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Trying to get @@servername remotely

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :Sql Server

I am trying to connect to a remote sql server and get the value of the @@servername, assign it to a variable and print it. Here is the code:



:SETVAR INSTANCE @@servername




When I run the sql in SSMS (2008 R2) I get the following:


Disconnecting connection from REMOTE_SERV\MYINSTANCE...

Is it possible to do what I am trying to do?




View Complete Post

More Related Resource Links

MS Ent Lib:How do I obtain the ServerName associated with the DBCommand object?



The application I am currently working on uses Microsoft Enterprise Library Data Access block for Data Access.

I have pasted the following method to provide context:


 public static DataSet ExecuteDataSet(string connection, string procName)
            DataSet ds = null;
                SqlDatabase db = new SqlDatabase(connection);
                DbCommand dbCommand = db.GetStoredProcCommand(procName);
                ds = db.ExecuteDataSet(dbCommand);
                return ds;
            catch (Exception ex)
               //Exception handling code


In the next release we are planning to use SQL Server 2008 R2 as our database and we will be implementing mirroring to provide automatic failover.

I have been tasked with rewriting the DAL to take advantage of this.

A sample  connection string used by the application today is as below:


Help with connecting to SqlExpress 2005 remotely


So I've intalled SQL 2005 Express and Sql Server Management Studio Express (SSMSE). I don't have any problems connecting to it using Windows authentication. But I would like to set it up so that I can log in using Sql Server Authentication with a username and password.

My Problem

But I'm getting an error message of "A connection was successfully established with the server, but then an error occured during the login process. (provider: Shared Memory Provider, error: 0- No process is on the other end of the pipe) (Microsoft SQL Server, Error: 233).

What I've done

I've created a new "Login" in the Security node. Provided all necessary role access level. Granted permission to connect to database and enabled login.

I've used the Sql Server Surface Area Configuration to set the Remote Connection type to "Using TCP/IP only" or "Using Both TCP/IP and named pipes" (tried both, but in either situation I get the same error message when attempting to login to SSMSE with the user name and password). I also made sure to restart the service.

What do I need to do to fix this problem? 

Share Database Remotely

I have developed desktop  application i.e ERP in vs 2008 C# ,Sql Server 2005 My client have two office distance approx. 2-4 kms I want  install in both office  but how to share database  ,i don't know, so plz  help me. Through LAN  is working fine Wired LAN is not Possible what could be other solution?

Remotely access winform application through admin panel

I am going to develop following application but not sure how to do this   Application will run different instances for various clients on different servers.     Each instance will run on different criteria stored in database managed by an admin.     Would like to be able to run this from the admin section.     Maybe using a server command line component and pipin the output into a web based admin? -- Whatever you think is best.     This application will run basically 24-7   Any best solution, idea etc

how to use sql database remotely(sql server 2005)

hi friends... when i want to connect my pc to sql server then the error comes........ A network-related or instance-specific error occurred while stabling 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: Named Pipes Provider,error:40-Could not open a connection to Sql server)(Microsoft Sql Server,Error:233)   so plz check it and give me advise how can i connect sql server remotely   thanks friends    

Login Failed When Using IP ( But OK When Using ServerName (http://intranet)

  Current Setup: 1. WSS 3.0 Server Windows 2008 Server R2 WSS 3.0 SP2 x64 Server Name: intranet IP Addr: Windows Internal Database (Standalone Setup Option) 2. AD Server Windows 2003 Standard Server Server Name: abc-dc1 IP Addr: Domain: abc Scenario: When using http://intranet, login ok for both domain id abc\eric or local admin account intranet\Administrator When using, login ok for local admin account intranet\Administrator, but failed for domain id abc\eric. Appreciate for any help on this issue.

When to add "tcp:" to "Server name:" connecting from SSMS remotely

Having read in [1] that to connect to the database engine from another computer using SSMS "In the Server name box, type tcp: to specify the protocol, followed by the computer name... type tcp:<computer_name>. In our example for a named instance, type tcp:<computer_name>,49172", why do I connect to remote server without adding "tcp:"? I do not remember adding "tcp:" connecting to earlier versions of MS SQL server either... [1] Connecting to the Database Engine from Another Computer(MS SQL Server 2008 R2) http://msdn.microsoft.com/en-us/library/ms345343.aspx#otherComp

Cannot connect to Reporting Services in SSMS using Servername



Kindly help me as i can't connect to Reporting Services in SSMS using SERVERNAME but using URL(http://localhost/ReportServer) I can connect. Here is the error I received. Please advice.

TITLE: Connect to Server

Cannot connect to PERRYDUNDOC-W7.


Unable to connect to the server at SERVERNAME. The specified URL might not be valid or there might be a problem with the report server version or configuration. Specify a different URL, or contact your server administrator to verify that the report server runs SQL Server 2008 or later. Additionally, if you are trying to connect to a SharePoint-integrated report server, verify that SharePoint is installed on the server and that the report server uses SharePoint integrated mode. (Microsoft.SqlServer.Management.UI.RSClient)




how to call c#.net assembly remotely.


Hi all,

   am created a .net assembly in one machine, how do i call this assembly remotely from another machine. Can u give the sample code for this.




Change windows password remotely


Hi all,

Not sure where to post this, so I thought I'd start here...

I am designing a website (ASP.NET in VB) and I'd like it to have the following features: to generate a random string to be used as a password. This bit I should be able to manage, the bit I don't have a clue on is how I can pass this to a Windows machine (on a workgroup not AD) to change a user's account password.

In summary, can anyone help me to remotely change a user's password on a Windows workgroup machine using ASP.NET with VB?

FYI, I have full administrator access.

Thanks in advance for any help you can provide.
Jim :-)

Get the local servername in script task

Hi there. I want to get the server name using script task. Is there any way to do this? Thanks

Executing SSIS remotely via ManagedDTS



I am reposting this since this special problem was hidden too deep in my previous thread.

I prepared a tiny console app to run a SSIS package, see code below. I can run this executable on the SQL Server machine and it executes just fine. I can pass variables, get return values, examine SSIS error in managed code all fine.

When I start that same executable on a webserver which can access ports 135 and 1433 of that same SQL Server, then I am getting the following error messages from the package in my managed code:


The task has failed to load. The contact information for this task is "".

There were errors during task validation.

The package cannot execute because it contains tasks that failed to load.


I have no clue what went wrong, does someone know what the issue could be or how I could narrow it down? The package is stored in msdb BTW and the user executing it on the webserver has admin rights on the sql server machine, is db_owner and has all possible rights for the SSIS package.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

Connect to sql server 2008 remotely via internet


Hey'a guys kinda new in sql server..

Im developing a C# windows application.

I want to connect to my sql server remotely outside our local area network. Basically I want to connect through the internet. can I do that? How? through terminal services? any reference on how to install/ setup terminal services on my windows server..?

What could be the best connection string for that matter that I can use for my ADO.net?

my connection string is:

@"Network Library = dbnmpntw; Server =  "servername\domain name,1433" ; DataBase = "databasename" ; User ID = "username " ; Password = "password ";

Ive tried going to connectionstrings.com but couldnt find one that works over the net.

Do I have to add the static Ip in my connection string?

When connecting through LAN everthing works fine. Problem happens when i try to connect outside our office.

I think maybe the problem is in my connection string....

"server was not found or was not accessible"

Report Manager URL http:///Reports is not working in SharePoint Integrated Mode


Hello Friends,

I am ali, I am so confused why the Report manager URL(http://<servername>/Reports is not working in sharpoint integrated mode. 

In my local system

1. at the time of SQL Server 2008 R2 installation Reporting services enabled In Native mode.
2  In Reporting service config manager tool http://<serverName>/Reports URL is working in Native mode. Here i am able to create New Roles.
3. In Reporting service config tool When i create a new database in sharepoint integrated mode, the the Report Manager URL http://<ServerName>/Reports not working, gettig this error "This operation is not supported on a report server that is configured to run in SharePoint integrated mode. (rsOperationNotSupportedSharePointMode)"
4 . From both databases(In native mode and sharepointmode) the the webservice URL http://<servername>/ReportServer working fine.

Reporting Services Config manager :

Cannot access database remotely



I'm working on a project.  It is a .net project using asp and c# in visual studio 2008 enterprise.  I have sql server 2008 enterprise as my database.  It is working perfect locally.  However when I put the database and the web app on the server, I get the following 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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)

 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the p

Problem remotely connecting to sql server 2008 express



I am trying to connect to sql server 2008 express remotely from visual studio 2010. On the server, I've enabled the sql browser service, enabled the TCP/IP and named pipes protocols. Also for firewall I added exceptions for the sqlserver and sqlbrowser instances. I tried connecting to the server through telnet by specifying the ip and port and it worked. But when I try connecting from visual studio through sql client I get the following error:

Timeout expired, the timeout period ellapsed prior to the completion of the operation or the server is not responding. Any ideas what might be the problem?

Thank you,


Report not visible under http://servername/Reportserver



when i navigate to http://servername/Reportserver , i am unable to see the report i have on this server. It displays only

 26 October 2010 13:23        <dir> Data Sources

where as it should also display to me ILM_HR_Report which is what i want to see

                 26 October 2010 13:23        <dir> Data Sources 26 October 2010 13:23 <dir> ILM HR Report


I have ensure that the login in SQL has read permissions on the database from where data is being read.

In Report Manager a role has been created for this login with all permissions (browser, content manager etc...)

Not sure what am i missing here.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend