Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2007, 06:10 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataTables and Visual Studio

Hello. 1st Message. If too long, forgive. Question is regarding DataTables. Wet behind the ears also but some early experience w-VB6 & SQl. No, no expert. I analyse data for use by the big guys. Learning how they use it as far as datagrids, datatables & forms. Anyway. Simply put. I have a form with 3 datagridviews (Objects)bringing in 3 tables to have data compared and hopefully edited. Not using DataSets but DataTables instead. Struggle is: How do I code an event for clicking on the datagridview field & populate a text box object with the datagrid data selected. Hope this is the right forum for this simple but long query.
'My Connection String....
MyConn.ConnectionString = My.Settings.MyConn
MyConn.Open()

DT = New DataTable
DT2 = New DataTable
DT3 = New DataTable

'Setting my SelectCommand properties....
MyCmd.CommandType = CommandType.Text
MyCmd.CommandText = "SELECT Top 10 ODppid,ODid,PayPlanStatus FROM ODPayPlan ORDER BY ODppid"

MyCmd2.CommandType = CommandType.Text
MyCmd2.CommandText = "SELECT Top 10 ODid, TransCode,TRid,TransVar FROM ODTrans ORDER BY ODid"

MyCmd3.CommandType = CommandType.Text
MyCmd3.CommandText = "SELECT Top 10 ODid,PropId,vVarChar,vDate FROM ODdata ORDER BY ODid"

Dim MyQryString As String = MyCmd.CommandText
Dim MyQryString2 As String = MyCmd2.CommandText
Dim MyQryString3 As String = MyCmd3.CommandText

Dim MySDA As SqlDataAdapter = New SqlDataAdapter(MyQryString, MyConn)
Dim MySDA2 As SqlDataAdapter = New SqlDataAdapter(MyQryString2, MyConn)
Dim MySDA3 As SqlDataAdapter = New SqlDataAdapter(MyQryString3, MyConn)

'Fill the DataGrid...
MySDA.Fill(DT)
MySDA2.Fill(DT2)
MySDA3.Fill(DT3)
Thank You

DeaconKen
 
Old January 29th, 2007, 12:33 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For those interested I figured out the required code: Use a Sub for each DataGridView then use this code -
Private Sub DGV1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellEnter
        If sender.selectedcells.count > 0 Then
            '//Only show if selected cell is in any column
            Dim iRow As Int32
            Dim iCol As Int32
            If CType(sender, DataGridView).SelectedCells(0).ColumnIndex >= 0 Then
                iRow = e.RowIndex
                iCol = e.ColumnIndex
                Me.txtBxTest.Text = DGV1.CurrentRow.Cells(1).Value
            End If
        End If
    End Sub

DeaconKen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio VS. Visual Web Developer expr Astrocloud BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 November 23rd, 2008 03:10 PM
FTP in Visual Studio 2005 Pro (Visual Basic) shoopes VB How-To 1 June 29th, 2006 02:08 PM
Visual Studio 2003 vs. Visual Studio 2005 eitanbarazani C# 2005 4 May 9th, 2006 01:34 AM
Visual Studio .net2003 and Visual Studio 2005 Gert Visual C++ 1 January 24th, 2006 05:10 AM
Visual studio 6 or visual studio .NET chaitannyam Visual C++ 1 November 13th, 2005 09:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.