?
Solved

ASP.Net 1.1 and SQL Server 2000

Posted on 2008-02-03
12
Medium Priority
?
257 Views
Last Modified: 2011-10-19
I have recently joined a new company.
I have a computer with both .Net 1.1 & 2.0 installed. Also the Sql server 2000 client components are installed.

If I create a winforms application, it works fine. but if I create a basic ASP.Net application & try connecting to a sql server, I get a message that "SQL server does not exist or access denied".

The sql server does exist for sure, hence it probably is some kind of access issue, TCP/IP, Named pipes or something else. I have also enabled the TCP\IP and namedpipes.

The funny thing is that the ASP.Net applications that the previous programmer had created, they still do work. only new applications that I create are not working.

Attached in the code snippet is the very basic ASP.Net application that I tried to create on this computer, but it gives a message that "SQL Server does not exist or access denied".

Please advise, why would this be happening.
Thanks for your help in advance.

 
----------------------********************************************************
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sqlconn As New SqlClient.SqlConnection
             sqlconn.ConnectionString = "server= Earth;database=CTSY2K;user id=Username;password=******;Network Library =dbmssocn"
        
        Try
            sqlconn.Open()
        Catch sqlerror As Exception
            Response.Write(sqlerror.Message)
        End Try
 
        If sqlconn.State = 1 Then
            Response.Write("SQL server is connected")
        End If
 
    End Sub

Open in new window

0
Comment
Question by:vdesai_8
  • 6
  • 4
11 Comments
 
LVL 8

Expert Comment

by:Yiogi
ID: 20811480
why do you need network library in the parameters? This would force it to use TCP/IP in an ADO connection but since you are using VB.Net you are using an SQL Client connection. Try deleting that.
0
 
LVL 39

Accepted Solution

by:
appari earned 1200 total points
ID: 20811546
did you try with IPaddress instead of the server name, try like this(replace xxx.xxx.xxx.xxx,1433 with actual ip address and the port. default is 1433)

sqlconn.ConnectionString = "server= xxx.xxx.xxx.xxx,1433;database=CTSY2K;user id=Username;password=******;Network Library =dbmssocn"

or this

sqlconn.ConnectionString = "Data Source=xxx.xxx.xxx.xxx,1433;Network Library=DBMSSOCN;Initial Catalog=CTSY2K;User ID=Username;Password=Password;"
0
 

Author Comment

by:vdesai_8
ID: 20811788
sqlconn.ConnectionString = "server=xxx.xxx.xxx.xx;database=CTSY2K;user id=sa;password=xxxxxxx"

The above connection string worked! Thanks Gurus!
but I am concerned about 2 things:

1). I would like to give the name of server instead of the IP address, in the connection string.
eg: sqlconn.ConnectionString = "server=Testserver;database=CTSY2K;user id=sa;password=******"

2). If I mention the port 1433 in the connection string, it gives an error, that the specified SQL server could not be found. not sure why...

Please advise.

Thanks!

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 8

Expert Comment

by:Yiogi
ID: 20812666
Perhaps your SQL is not running on the default port which is 1433. You can run your Server Network utility and see what port SQL is running from.

Also if it's in your local network and you cannot access it with the name then you might need to configure it on each machine in the Client Network utility to use named pipes instead of TCP/IP and specify the pipe name, or use TCP/IP and not named pipes. You can do whatever suits your case.
0
 

Author Comment

by:vdesai_8
ID: 20817062
Yiogi,

The sql server is running on port 1433. Also my Client network Utility is set up as shown in the attached file.

not sure why I cannot access the connection string using the servername rather than IP address.

Please help. Thanks!

Doc3.doc
0
 
LVL 8

Assisted Solution

by:Yiogi
Yiogi earned 800 total points
ID: 20824485
Hi vdesai,

Apologies for my late reply but for some reason I couldn't download the file all day long for some reason. Are you running the sql server on a default instance? If not then try this instead in your pipe:
\\testserver\pipe\MSSQL$INSTANCENAME\sql\query

If you are your pipe looks correct but it would be best if you had verified it with the one shown in the server network utility where your server is installed.

Also can you try and see if can see the machine with it's name on your network? Maybe it just can't resolve the name correctly. Try an nslookup and see if the name matches the correct ip.
0
 

Author Comment

by:vdesai_8
ID: 20829015
Yes Yiogi, the SQL Server is running on a default instance. I verified the pipes too on both Client & Server, & they do match.

How can I perform nslookup?

Thanks.
0
 
LVL 8

Expert Comment

by:Yiogi
ID: 20830241
open a command prompt and type "nslookup servername"
0
 

Author Comment

by:vdesai_8
ID: 21026765
Dear experts I have to work on some other task for the next three weeks, so please pardon me if I am not able to reply for the next 2 to 3 weeks. Thanks!
0
 

Author Closing Comment

by:vdesai_8
ID: 31427691
Thanks experts! & sorry for the late reply.
0
 

Author Comment

by:vdesai_8
ID: 21289203
Thanks experts! & sorry for the late reply.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question