Results 1 to 4 of 4

Thread: how to connect vb.net to sql server

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2003
    Posts
    3

    Unhappy how to connect vb.net to sql server

    Hi,

    I am a new user of VB.net. Could you tell me how to connect Vb.net to sql 2000 server?

    Many Thanks


  2. #2
    Lively Member
    Join Date
    Jul 2003
    Location
    Kuala Lumpur (Malaysia)
    Posts
    92

    2 Methods ?

    Hi,

    Programmatically, use connectionstring as in the VB6 but dotnet use dataadapter for that purpose.

    Another one is the "Drag and Drop" the connection to your form and give some setting.

  3. #3
    Lively Member
    Join Date
    Jul 2003
    Location
    Kuala Lumpur (Malaysia)
    Posts
    92

    This is the best site..

    Hi,

    The suitable connectionstring can be found here :

    http://www.able-consulting.com/ado_c...f=ado_conn.htm

  4. #4
    Junior Member
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    18
    You have several way of doing this. I obtains lists of servers, databases and tables with SQLDMO like this:

    Private serverobj As SQLDMO.SQLServer
    Private conn As SqlClient.SqlConnection
    Private adapter As SqlClient.SqlDataAdapter
    Private server As String
    Private database As String

    Public Function GetServers() As ArrayList
    Dim servers As ArrayList
    Dim i As Integer
    Dim applicatie As SQLDMO.Application
    Dim lijst As SQLDMO.NameList
    servers = New ArrayList
    applicatie = New SQLDMO.Application
    lijst = applicatie.ListAvailableSQLServers
    For i = 1 To lijst.Count
    servers.Add(lijst.Item(i))
    'MsgBox(lijst.Item(i))
    Next
    Return servers
    End Function

    Public Function GetDatabases() As ArrayList
    Dim databases As ArrayList
    If MakeConnection() Then
    Dim db As SQLDMO.Database
    databases = New ArrayList
    For Each db In serverobj.Databases
    databases.Add(db.Name)
    Next
    Else
    Return Nothing
    End If
    Return databases
    End Function

    Private Function MaakConnectie() As Boolean
    On Error GoTo errorhandler
    'Maak verbinding met server
    serverobj = New SQLDMO.SQLServer
    serverobj.LoginSecure = True
    serverobj.Connect(server)
    Return True
    end function

    And making updates, I do with objects from the SQLClient namespace

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width