Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Can not connect to sql 2005

Author  Topic 

dev45
Yak Posting Veteran

54 Posts

Posted - 2009-02-22 : 13:21:28
Hi,
i am developing a vb.net (visual studio 2005) application using SQL 2005 as backend. I am using the following piece of code to locate the available instances of SQL :
Dim dtServers As New DataTable
dtServers = SmoApplication.EnumAvailableSqlServers(False)

This code fetches the SQL Server that i have installed on my pc (let's say mySQLServer). There are also 2 textboxes in which i key in the login credentials (let's say : username = sa, password = sa). After that, a connection string is created :
(the database name is fixed : myDB)

connStr= "Provider=SQLOledb.1;Initial Catalog=myDB; UserId=sa;Password=sa;Data Source=mySQLServer"

A connection is opened and everything works fine...
where's the problem then ? It only works when i am running the client application in the same PC where the SQL resides. When i try to port it to another pc, it gives me and error : [DBNETLIB] [(ConnectionOpen connect()).] SQL does not exist or access is denied.

The problem is that i am not at all into network stuff so basically dont know what to do. I am not even sure if the PCs are in a network (i think they are in a workgroup). The sure thing is that the code that locates the SQL Servers is working fine on all PCs because i can see the name of the PC running the SQL Server.

I am open to any suggestion...:)

Thanks ,
theodore

ps: SELECT SERVERPROPERTY('productversion') --> 9.0.3077.00
SELECT SERVERPROPERTY ('productlevel') --> SP2
SELECT SERVERPROPERTY ('edition') --> Developer Edition

hey001us
Posting Yak Master

185 Posts

Posted - 2009-02-22 : 15:24:24
try this.
telnet <servername> <port no. default 1433>
firewall issue if timeout

hey
Go to Top of Page

dev45
Yak Posting Veteran

54 Posts

Posted - 2009-02-23 : 07:11:27
Hi,
thx for the help, i will try it out when back at home.
In the meanwhile, yesterday night,i found out that i could connect using the IP and port instead of the server name
so, if the connection string is : "Provider=SQLOledb.1;Initial Catalog=myDB; UserId=sa;Password=sa;Data Source=192.168.1.1,1433" it connects ok in remote mode. That means that the dns name (?) is not resolved ?
Thx again
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2009-02-23 : 15:28:10
Go to C:\WINDOWS\system32\drivers\etc\host file and add your <IP address> and <host name>. then it will resolve the dns name.

hey
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-23 : 16:01:29
Adding it to the host file is just creating an alias, it does not fix DNS.

I never update the host file. Instead, I create SQL aliases.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2009-02-23 : 18:43:24
Yes we do use alias in SQL Server.
We need to add into the host file if we don’t have SQL instance on the client PC or Application server.


hey
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-23 : 18:51:06
No you don't. SQL Server client tools are not required to add a SQL alias. You can add a SQL alias via regedit or even via an ODBC DSN (network configuration button).



Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2009-02-23 : 19:41:03
Sounds good, I never experienced that.
can you explain me about regedit, under where to add?
Thank you


hey
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-23 : 20:26:44
SQL aliases are stored here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2009-02-23 : 20:57:10
Cheers

hey
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-23 : 22:04:56


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -