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