|
-
Sep 7th, 2008, 10:05 AM
#1
Thread Starter
Addicted Member
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
-
Sep 8th, 2008, 10:11 AM
#2
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:
Option Strict On
Imports System.Data.SqlClient
Public Class Form1
Private myConnection As SqlConnection
Private Sub OpenDB()
myConnection = New SqlConnection("Integrated Security=SSPI;" _
& "Persist Security Info=False;Initial Catalog=xxxxxxxxx; " _
& "Data Source=xxxxxxxxx")
myConnection.Open()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
OpenDB()
End Sub
End Class
-
Sep 8th, 2008, 08:59 PM
#3
Thread Starter
Addicted Member
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
-
Sep 8th, 2008, 09:03 PM
#4
Re: connecting 2005 vb to SQL server 2000
 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
-
Sep 8th, 2008, 09:12 PM
#5
Thread Starter
Addicted Member
Re: connecting 2005 vb to SQL server 2000
 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
-
Sep 8th, 2008, 09:28 PM
#6
Re: connecting 2005 vb to SQL server 2000
 Originally Posted by sphericalx
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|