Using ADO.NET to get data
1 post
• Page 1 of 1
Using ADO.NET to get data
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: 82
- Joined: Wed Dec 02, 2009 12:10 am
- Location: Ithaca, NY, USA
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group