<br><font size=2 face="sans-serif">Dobry den, </font>
<br>
<br><font size=2 face="sans-serif">Skusal ste niekto pristup do databazy
ADO.NET a IronPython? </font>
<br>
<br><font size=2 face="sans-serif">Napr. toto citanie pomocou Readeru mi
funguje:</font>
<br>
<br><font size=2 face="Courier New">----- priklad -----</font>
<br><font size=2 face="Courier New">...</font>
<br><font size=2 face="Courier New">### Pouzitie ADO.NET</font>
<br><font size=2 face="Courier New">import clr</font>
<br><font size=2 face="Courier New">import System</font>
<br><font size=2 face="Courier New">clr.AddReference("System.Data")</font>
<br><font size=2 face="Courier New">import System.Data</font>
<br><font size=2 face="Courier New">from System.Data.OleDb import OleDbConnection
as dbconnection</font>
<br>
<br><font size=2 face="Courier New"># Connection String</font>
<br><font size=2 face="Courier New">connectstr='PROVIDER=IBMDA400.DataSource.1;DATA
SOURCE='+csebk+'; USER ID='+userid+'; PASSWORD='+pwd</font>
<br>
<br><font size=2 face="Courier New"># Vytvorit spojenie</font>
<br><font size=2 face="Courier New">dbcon=dbconnection(connectstr)</font>
<br><font size=2 face="Courier New">dbcon.Open()</font>
<br>
<br><font size=2 face="Courier New"># Vytvorit SQL Command</font>
<br><font size=2 face="Courier New">dbcmd = dbcon.CreateCommand()</font>
<br><font size=2 face="Courier New">dbcmd.CommandText = "SELECT *
FROM r000100T.r000270V"</font>
<br>
<br><font size=2 face="Courier New"># Citat data</font>
<br><font size=2 face="Courier New">reader = dbcmd.ExecuteReader()</font>
<br>
<br><font size=2 face="Courier New">count=0</font>
<br><font size=2 face="Courier New">while reader.Read():</font>
<br><font size=2 face="Courier New"> count +=1
</font>
<br><font size=2 face="Courier New"> print "%10s %10s %10s %10s"
% (reader[0], reader[1], reader[2], reader[3]) </font>
<br>
<br><font size=2 face="Courier New">print "pocet viet v tabulke je:
%d" % count</font>
<br>
<br><font size=2 face="Courier New"># zavret reader</font>
<br><font size=2 face="Courier New">reader.Close()</font>
<br><font size=2 face="Courier New"> </font>
<br><font size=2 face="Courier New"># Ukoncit spojenie</font>
<br><font size=2 face="Courier New">dbcon.Close()</font>
<br><font size=2 face="Courier New">----- koniec prikladu -----</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">Ked ale skusim pouzit dataadapter a
dataset, t.j. zhruba takto </font>
<br>
<br><font size=2 face="Courier New">----- priklad -----</font>
<br>
<br><font size=2 face="Courier New">...</font>
<br><font size=2 face="Courier New">from System.Data.OleDb import OleDbConnection
as dbconnection</font>
<br><font size=2 face="Courier New">from System.Data.OleDb import OleDbDataAdapter
as dbdataadapter</font>
<br><font size=2 face="Courier New">from System.Data import DataSet as
dataset</font>
<br>
<br><font size=2 face="Courier New"># Connection String</font>
<br><font size=2 face="Courier New">DSN='PROVIDER=IBMDA400.DataSource.1;DATA
SOURCE='+csebk+'; USER ID='+userid+'; PASSWORD='+pwd</font>
<br><font size=2 face="Courier New">print DSN</font>
<br><font size=2 face="Courier New">conn=dbconnection(DSN)</font>
<br><font size=2 face="Courier New">conn.Open()</font>
<br>
<br><font size=2 face="Courier New">dataadapter = dbdataadapter("SELECT
* FROM r000100T.r000270V", conn)</font>
<br><font size=2 face="Courier New">#rs = System.Data.DataSet("MyDataSet")</font>
<br><font size=2 face="Courier New">rs=dataset("MyDataSet")</font>
<br><font size=2 face="Courier New">dataadapter.Fill(rs,"MyTable")</font>
<br><font size=2 face="Courier New">#print rs</font>
<br><font size=2 face="Courier New">row= rs.Tables(0).Rows(0)</font>
<br><font size=2 face="Courier New">...</font>
<br><font size=2 face="Courier New">----- koniec prikladu -----</font>
<br>
<br><font size=2 face="sans-serif">dostanem na poslednom uvedenom riadku
chybu </font>
<br><font size=2 face="sans-serif">"DataTableCollection object is
not callable"</font>
<br>
<br><font size=2 face="sans-serif">Mate niekto funkcny priklad jak pouzit
DataSet v IronPythone?</font>
<br><font size=2 face="sans-serif"><br>
Mgr. Ing. Roman MIKLÓ© <br>
Prvá stavebná sporiteµňa a.s. <br>
Bajkalská 30, P. O. Box 48 <br>
829 48 Bratislava 25 <br>
Tel.: +421/ 2 / 582 31 174 <br>
Fax: +421/ 2 / 582 31 109 <br>
</font>