Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recordset in a grid
Message
From
10/05/2003 15:22:43
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00786951
Message ID:
00787087
Views:
18
>dear cetin,
>thank you for replying to my message
>you mentioned msdatagrid :
>do i have to create the connection from the msdatagrid or is there a way to link the recorset to the msdatagrid from the visual foxpro defined connection ?
>thank you in advance

Voltaire,
Here is a sample code for datagrid. Edit connection string definition to match an existing connection in your environment :
#Define OLEDBCONNECTSTRING 'Provider=SQLOLEDB.1;'+;
   'Integrated Security=SSPI;'+;
   'Initial Catalog=Northwind; Data Source=servername'

oForm = Createobject('frmSample')
oForm.Show
Read Events

Define Class frmSample As Form
  Top = 0
  Left = 0
  Height = 400
  Width = 500
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"

  Add Object myDataGrid As OleControl With ;
    Top = 10, ;
    Left = 10, ;
    Height = 380, ;
    Width = 480, ;
    OleClass = 'MSDataGridLib.DataGrid',;
    Name = "myDataGrid"

  Procedure Init
    This.AddProperty('oConn',Createobject('ADODB.Connection'))
    This.AddProperty('oRS',Createobject('ADODB.RecordSet'))

    With This.oConn
      .ConnectionString = OLEDBCONNECTSTRING
      .Mode = 16
      .Open
    Endwith
    With This.oRs
      .ActiveConnection = This.oConn
      .Source = 'select * from customers'
      .CursorLocation= 3  && adUseClient
      .CursorType= 3 && Static
      .LockType= 4  && adLockBatchOptimistic
      .Open
    Endwith
    Local oRs As ADODB.Recordset

    With This.myDataGrid
      .Datasource=This.oRs
      .Caption = "Customers Table"
    Endwith
  Endproc

  Procedure QueryUnload
    If Messagebox('Save ?',4+32,'Save changes') = 6
      This.oRs.UpdateBatch
    Endif
    This.oConn.Close
    Clear Events
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform