Results 1 to 7 of 7

Thread: Sage project from VS 2010

Threaded View

  1. #6

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    8

    Re: Sage project from VS 2010

    Hi J, thanks for the help, it has taken a bit of trying but i have got data in the DGV and seems to be working so far. Here is what I have got to date, Is this on the right track?

    Regards skaman

    form so far Code:
    1. Imports System.Data.Odbc
    2. Public Class Form2
    3.  
    4.     Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    5.  
    6.  
    7.     End Sub
    8.  
    9.  
    10.     Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    11.         Call FillDataGrid()
    12.     End Sub
    13.  
    14.  
    15.  
    16.     Sub FillDataGrid()
    17.  
    18.         Dim ObjConn As OdbcConnection
    19.         Dim DBComm As OdbcCommand
    20.         Dim StrConnectionString As String
    21.         Dim StrSql As String
    22.         Dim StockTable As New DataTable
    23.  
    24.         StrConnectionString = "Dsn=SageLine50v13;uid=****;Pwd=****;"
    25.         StrSql = "SELECT STOCK_CODE, Description FROM STOCK"
    26.         ObjConn = New OdbcConnection(StrConnectionString)
    27.         ObjConn.Open()
    28.         DBComm = New OdbcCommand(StrSql, ObjConn)
    29.  
    30.  
    31.  
    32.         Using DtaReader As OdbcDataReader = DBComm.ExecuteReader()
    33.  
    34.             StockTable.Columns.Add("Selected", GetType(Boolean)).DefaultValue = False
    35.             StockTable.Load(DtaReader)
    36.             MyDataGridView.DataSource = StockTable
    37.  
    38.         End Using
    39.  
    40.         ObjConn.Close()
    41.         DBComm.Dispose()
    42.         ObjConn.Dispose()
    43.     End Sub
    44.  
    45.  
    46.  
    47.  
    48. End Class
    Last edited by skamanchero; Mar 31st, 2011 at 04:23 PM.

Tags for this Thread

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