SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to connect to a db in sql 2000 using vs2010
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ashley.s
Starting Member

Mauritius
9 Posts

Posted - 01/16/2012 :  07:58:24  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 01/16/2012 :  08:22:42  Show Profile  Reply with Quote
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

Mauritius
9 Posts

Posted - 01/17/2012 :  01:29:15  Show Profile  Reply with Quote
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 Posts

Posted - 01/17/2012 :  07:38:04  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000