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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to connect to a db in sql 2000 using vs2010

Author  Topic 

ashley.s
Starting Member

9 Posts

Posted - 2012-01-16 : 07:58:24
hi All,
Hope you are doing fine. I am a vb beginner and currently using vs2010. I have an application using sql server 2000 and I am trying to develop something to access data from that database. First of all, I am trying to connect to a database there which I can't. Below is my code. I would be very grateful if anyone of u can advise. To manage the databases, sql server enterprise manager is used. I have noticed there that there is no instance name (Is that normal). Windows authentication is being used to log in.


Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim objconnection As SqlConnection = New SqlConnection("server=192.168.0.9;database=databasename;Integrated Security=True;")

Public Sub Connect2Database()
Try
objconnection.Open()
MsgBox("You are connected")
objconnection.Close()
Catch
MsgBox("You are not connected")

End Try
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Connect2Database()

End Sub
End Class

Result: "You are not connected"

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-16 : 08:22:42
Your code looks ok to me, but I am not very familiar with SQL 2000, so I could be missing something as well. Check out this page and use one of the formats listed there for connection string. http://www.connectionstrings.com/sql-server Also, make sure that you can connect to the database on 192.168.0.9 using enterprise manager, or at the very least ping the server from your computer. Is the server up and running?
Go to Top of Page

ashley.s
Starting Member

9 Posts

Posted - 2012-01-17 : 01:29:15
Dear Sunitabeck,
thank you for your reply. The server is up and running. I can ping server as well. I have tried the format you mentioned but in vain.What else can you suggest?
Go to Top of Page

xpresshred11
Starting Member

1 Post

Posted - 2012-01-17 : 07:38:04
If you want connect front-end visual studio 2010 to SQL Server 2000 then you must write a connection string go to .NET platform then pass name of database.

[url=http://www.xpresshred.com/]Denver Paper Shredding[/url]
[url=http://www.xpresshred.com/]Industrial Paper Shredder[/url]
Go to Top of Page
   

- Advertisement -