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
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?