2

I have to make a connection to a SQL Server database which is hosted at ip:aaa.xxx.yyy.zzz the user of this server is 'user' and password is 'password'. Database name is 'datos'

I tried this but it didn't work.

Dim myConn As SqlConnection
Dim myCmd As SqlCommand
Dim myReader As SqlDataReader
Dim results As String

myConn = New SqlConnection("Server=aaa.xxx.yyy.zzz;Database=datos;Trusted_Connection=True")
myConn.Open()

I also tried:

myConn = New SqlConnection("Server=aaa.xxx.yyy.zzz;Database=datos;User ID=user;Password=password")

EDIT

This code is into a sub named 'SQL', when it excecute myConn.Open() the sub finishes but shows no error.

Ip is on local network, and 'datos' was created on the local of the server using Microsoft SQL Server Management Studio

3
  • Explain what you mean by didn't work - did you get an error - if so: WHAT error? The second connection string seems pretty accurate to me ... Commented Nov 25, 2013 at 19:30
  • Is that IP on your local network? Are the database server and the sql browser service running? Commented Nov 25, 2013 at 19:35
  • I edited the question for more details. Commented Nov 25, 2013 at 19:53

2 Answers 2

4

No ports where declared in the IP eg .192.168.0.1:1033 , And instead of Database use Initial Catalog=datos

On the server you would have to set in sql server management the option of allowing remote connections to true, then in windows firewall activate the port used to connect to the sql server.

Full idea with the connection string...

"Server=192.168.0.1:1033\SQLEXPRESS;Initial Catalog=datos;uid=userid;pwd=password"

Sign up to request clarification or add additional context in comments.

Comments

0

Could be a lot of things, since you didn't specify what error you got, but as a general reference this site: http://www.connectionstrings.com/sql-server/ gives you lots of things to try.

Other things to confirm: is the firewall allowing traffic thru? Is the port set to something other than the default of 1433; did you configure the server to allow remote connections? Is tcp/ip enabled?...etc.

1 Comment

Although this is the accepted answer, it doesn't actually answer the question and simply asks for clarification. This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.