Click or drag to resize
RunGetCurrentConnection Method
Gets the current connection used in current search page.

Namespace:  Biolomics.BioCallback
Assembly:  Biolomics.BioCallback (in Biolomics.BioCallback.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static XConnection GetCurrentConnection()

Return Value

Type: XConnection
The current connection used in current search page.
Examples
This is a BioloMICS example
Example VB.Net
Imports System
Imports BioloMICS.BioCallback
Imports BioloMICS.SharedClasses

Public Class Program

    <STAThread()>
    Shared Sub Main()
        '    Create an instance of class Program and call its functions
        Dim c As New Program
        c.AddAndDeleteRecords()
    End Sub
    '    Write sub functions here
    Public Sub AddAndDeleteRecords()
        '    get the current connection
        Dim SqlCo As XConnection = Run.GetCurrentConnection()
        If SqlCo Is Nothing Then
            Return
        End If

        '    get the current layout
        Dim Layout As XDataLayout = Run.GetCurrentLayout()
        If Layout Is Nothing Then  '    no current layout in a search page
            Return
        End If

        '    get the current table 
        Dim TableDef As XTableDef = SqlCo.GetTableDef(Layout.TableKey)
        If TableDef Is Nothing Then   '    should never happen
            Return
        End If
        '    add two records. If RecordId1 < 0: there is an error
        Dim RecordId1 As Integer = Run.AddRecord(TableDef.UserName, "New Record 1")
        Dim RecordId2 As Integer = Run.AddRecord(TableDef.UserName, "New Record 2")

        '    delete the second record
        Run.DeleteRecord(TableDef.UserName, RecordId2)
    End Sub

End Class
See Also