Results 1 to 6 of 6

Thread: connecting 2005 vb to SQL server 2000

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    151

    connecting 2005 vb to SQL server 2000

    i'm currently using microsoft visual basic 2005 express edition and sql server 2000.

    as i am doing a window application and there is a need for mi to do a connection to the database but somehow vb 2005 edition is linked to sql server 2005 express edition.

    so is there some other way for mi to do the connection to sql server 2000 instead?

    thanks,

    ron

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: connecting 2005 vb to SQL server 2000

    Welcome to the forums.

    The connection that you are talking about is probably being done through some kind of wizard or bound something or other.

    If you use programming code, you can connect to whatever you want to connect to. Here is an example. Modify as necessary
    vb.net Code:
    1. Option Strict On
    2. Imports System.Data.SqlClient
    3.  
    4. Public Class Form1
    5.  
    6. Private myConnection As SqlConnection
    7.  
    8. Private Sub OpenDB()        
    9.         myConnection = New SqlConnection("Integrated Security=SSPI;" _
    10.      & "Persist Security Info=False;Initial Catalog=xxxxxxxxx; " _
    11.      & "Data Source=xxxxxxxxx")
    12.         myConnection.Open()        
    13. End Sub
    14.  
    15. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    16. OpenDB()
    17. End Sub
    18. End Class

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    151

    Re: connecting 2005 vb to SQL server 2000

    thnx, got it working already. ^^ below is my code, modified into a datagridview.

    Code:
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Dim SQLstr As String
        Dim str_connection As String = "Data Source=127.0.0.1;Integrated Security=SSPI;Initial Catalog=FinStudio;User Id=myuserid;Password=mypw"
        Dim mycon As SqlConnection
        Dim comUserSelect As SqlCommand
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
            SQLstr = "SELECT * FROM customers"
            mycon = New SqlConnection(str_connection)
            comUserSelect = New SqlCommand(SQLstr, mycon)
            Dim dataadapter As SqlDataAdapter = New SqlDataAdapter(comUserSelect)
            Dim ds As DataSet = New DataSet()
            '---open the connection and fill the dataset---
            mycon.Open()
            '---fill the dataset---
            dataadapter.Fill(ds, "Customers_table")
            '---close the connection---
            mycon.Close()
            '---bind to the DataGridView control---
            DataGridView1.DataSource = ds
            '---set the table in the dataset to display---
            DataGridView1.DataMember = "Customers_table"
            DataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders
        End Sub
    anyway, off topic question. for the datagridview, is ti possible that when the user click on a certain cells in the datagridview, that ROW of cells get highlighted? And also if the user were to double-click on a certain cells, all the values from that ROW appear on a messagebox?

    thanks,

    ron

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: connecting 2005 vb to SQL server 2000

    Quote Originally Posted by sphericalx
    anyway, off topic question. for the datagridview, is ti possible that when the user click on a certain cells in the datagridview, that ROW of cells get highlighted? And also if the user were to double-click on a certain cells, all the values from that ROW appear on a messagebox?

    thanks,

    ron
    New topic = new thread
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    151

    Re: connecting 2005 vb to SQL server 2000

    Quote Originally Posted by jmcilhinney
    New topic = new thread
    sorry, cuz dun wanna post too many thread. anyway i have created a new thread regarding the datagridview.

    http://www.vbforums.com/showthread.p...65#post3329065

    thanks,

    ron

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: connecting 2005 vb to SQL server 2000

    Quote Originally Posted by sphericalx
    sorry, cuz dun wanna post too many thread. anyway i have created a new thread regarding the datagridview.

    http://www.vbforums.com/showthread.p...65#post3329065

    thanks,

    ron
    There are tens, if not hundreds, of thousands of threads on this site already. Number is not an issue. The most important thing is that they are kept orderly so information is easy to find. One topic per thread and one thread per topic with descriptive titles for all threads means that everyone has the best chance of finding what they're after when they search, which everyone should do before posting.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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