0

I have a problem with connecting to a server which is another machine. When I try connecting to my machine with the following code, it works fine:

'connString = "Data Source = .\sqlexpress;" & _ '"Initial Catalog = one;" & _ '"Integrated Security = SSPI" Try conn = New SqlConnection(connString) conn.Open() MessageBox.Show("Connection Successful") Catch ex As Exception MessageBox.Show(ex.Message) End Try 

But when I try to get connected to another machine where SQL Server 2000 is installed, I get a timeout message. The code is as follows:

connString = "Server = xxx.xxx.xxx.xxx;" & _ "Initial Catalog = one;User Id=xxxx; Password=xxxxx;" & _ "Integrated Security = SSPI" Try conn = New SqlConnection(connString) conn.Open() MessageBox.Show("Connection Successful") Catch ex As Exception MessageBox.Show(ex.Message) End Try 

Can anyone please help me on this issue?

3
  • 1
    You supply two different log on type with SSPI and User Id/Password, but I guess this would cause an exception to be thrown. Can you ping the server? Commented Oct 7, 2010 at 9:28
  • Can no one edit this question so that the code appears correctly? Commented Oct 7, 2010 at 15:57
  • Can you connect to SQL Server using another tool, management studio, from your machine? Or try using the Visual Studio Server Explorer to connect to the SQL Server database and see the result. Commented Oct 7, 2010 at 16:06

2 Answers 2

1
Imports System.IO Imports System.Data.SqlClient Public Class Supplier Dim scon As New SqlConnection //you write your code in load event Private Sub Supplier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load scon = New SqlConnection("your connection string") scon.Open() End Sub Endclass 
Sign up to request clarification or add additional context in comments.

Comments

0

It will be great help if you can provide more information like exception stack trace / code will be helpful. Also make sure you are able to connect to the remote server with SQL Management Studio. Also if you are using SQL Authentication in the connection string, you don't require to provide "Integrated Security = SSPI". and vice versa.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.