Click here to Skip to main content
15,923,909 members
Home / Discussions / C#
   

C#

 
AnswerRe: SortedList Pin
hadad14-Apr-10 5:52
hadad14-Apr-10 5:52 
QuestionCsharp .Net image processing error Pin
djsproject14-Apr-10 5:24
djsproject14-Apr-10 5:24 
AnswerRe: Csharp .Net image processing error Pin
OriginalGriff14-Apr-10 5:35
mveOriginalGriff14-Apr-10 5:35 
GeneralRe: Csharp .Net image processing error Pin
djsproject14-Apr-10 6:08
djsproject14-Apr-10 6:08 
GeneralRe: Csharp .Net image processing error Pin
OriginalGriff14-Apr-10 6:14
mveOriginalGriff14-Apr-10 6:14 
GeneralRe: Csharp .Net image processing error Pin
Luc Pattyn14-Apr-10 6:37
sitebuilderLuc Pattyn14-Apr-10 6:37 
GeneralRe: Csharp .Net image processing error Pin
OriginalGriff14-Apr-10 8:12
mveOriginalGriff14-Apr-10 8:12 
QuestionProgramatically Connect to SQL Server instance After the VPN Connection is Established [modified] Pin
Vimalsoft(Pty) Ltd14-Apr-10 4:17
professionalVimalsoft(Pty) Ltd14-Apr-10 4:17 
Good Day All

I have a Code that Connects the VPN to a machine that is on a Different Network as mine and after the Connection is enabled, i use ado.net to access the SQL Server that is on the VPN Network and i tried the name instance of the SQL and i tried to use the IP Address to connect to it and it did not work. Here is my attempted code
private Boolean Connect_to_SQl()
{

    String Constring = @"user id=sa;password=oops;Server=96.444.444.233;Database=oDirectv3"; //This is a Fake IP

    SqlConnection con = new SqlConnection(Constring);

    Boolean Status = false;

    try
    {
        con.Open();

        if (con != null)
        {
            Status = true;
        }
        else
        {
            Status = false;
        }
    }
    catch (SqlException ex)
    {
        MessageBox.Show(ex.Message);
    }
    finally
    {

    }
    return Status;

}


My code fails when i try to Open the Connection

The Remote Machine is Using SQL 2008 and the Error is

{System.Data.SqlClient.SqlException: 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)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at RemoteUpdater.Form1.Connect_to_SQl() in C:\Work Development\Remote_Updater\RemoteUpdater\RemoteUpdater\Form1.cs:line 75} 


I have used the named instance and i have permission. am a sa in that machine

Thank you
Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified on Wednesday, April 14, 2010 10:54 AM

AnswerRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Eddy Vluggen14-Apr-10 5:08
professionalEddy Vluggen14-Apr-10 5:08 
GeneralRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Vimalsoft(Pty) Ltd14-Apr-10 21:43
professionalVimalsoft(Pty) Ltd14-Apr-10 21:43 
GeneralRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Eddy Vluggen14-Apr-10 22:48
professionalEddy Vluggen14-Apr-10 22:48 
GeneralRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Vimalsoft(Pty) Ltd15-Apr-10 21:51
professionalVimalsoft(Pty) Ltd15-Apr-10 21:51 
GeneralRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Eddy Vluggen16-Apr-10 2:34
professionalEddy Vluggen16-Apr-10 2:34 
GeneralRe: Programatically Connect to SQL Server instance After the VPN Connection is Established Pin
Vimalsoft(Pty) Ltd18-Apr-10 20:52
professionalVimalsoft(Pty) Ltd18-Apr-10 20:52 
QuestionConnect to my database csharp smart device Pin
Tunisien8614-Apr-10 2:41
Tunisien8614-Apr-10 2:41 
AnswerRe: Connect to my database csharp smart device Pin
Eddy Vluggen14-Apr-10 2:58
professionalEddy Vluggen14-Apr-10 2:58 
GeneralRe: Connect to my database csharp smart device Pin
Tunisien8614-Apr-10 3:30
Tunisien8614-Apr-10 3:30 
GeneralRe: Connect to my database csharp smart device Pin
Eddy Vluggen14-Apr-10 3:34
professionalEddy Vluggen14-Apr-10 3:34 
GeneralRe: Connect to my database csharp smart device Pin
Tunisien8614-Apr-10 4:28
Tunisien8614-Apr-10 4:28 
GeneralRe: Connect to my database csharp smart device Pin
Eddy Vluggen14-Apr-10 4:48
professionalEddy Vluggen14-Apr-10 4:48 
GeneralRe: Connect to my database csharp smart device Pin
Tunisien8614-Apr-10 4:50
Tunisien8614-Apr-10 4:50 
GeneralRe: Connect to my database csharp smart device Pin
Eddy Vluggen14-Apr-10 5:02
professionalEddy Vluggen14-Apr-10 5:02 
GeneralRe: Connect to my database csharp smart device Pin
Tunisien8614-Apr-10 5:13
Tunisien8614-Apr-10 5:13 
GeneralRe: Connect to my database csharp smart device Pin
Eddy Vluggen14-Apr-10 5:29
professionalEddy Vluggen14-Apr-10 5:29 
AnswerRe: Connect to my database csharp smart device Pin
Tunisien8619-Apr-10 23:02
Tunisien8619-Apr-10 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.