Using ADO.NET to get data

Using (or providing) Microsoft.NET Classes

Using ADO.NET to get data

Postby neeraj on Thu Mar 26, 2015 4:02 am

The beginning user may find the following helpful
      INIT;⎕USING
⎕PATH←'# ↑ #.U'
⎕USING←'' 'System' 'System.Data,system.data.dll' 'System.Data.Odbc'
∆∆conn←⎕NEW OdbcConnection(⊂'DSN=Dental; UID=user; PWD=pwd;')
∆∆conn.ConnectionTimeout←30


      CONNECT
∆∆conn.Open

:If ∆∆conn.(State≠State.Open)
r←'Failed to connect database' ⍝ TODO: better error handling
:EndIf


      T←EXEC statement;cmd;da;dt;⎕USING;⎕IO;H;R
⎕IO←1
⎕USING←'' 'System' 'System.Data,system.data.dll' 'System.Data.Odbc'
cmd←⎕NEW OdbcCommand(statement ∆∆conn)
da←⎕NEW OdbcDataAdapter(⊂cmd)
dt←⎕NEW DataTable(⊂'Query')
:If 0=da.Fill dt
T←0 2⍴⊂''
:Else
R←2011⌶dt
H←(dt.Columns[¯1+⍳dt.Columns.Count]).(ColumnName)
T←H R
:EndIf
neeraj
 
Posts: 77
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest