Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet393/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   389   390   391   392   393   394   395   396   ...   453
FIgURE 17-21: 
Select the Customers table for this example.
FIgURE 17-22: 
The data source
is ready to use in the example
extension.
548592c17.indd 382
2/24/10 12:49:39 PM
www.finebook.ir


Using Visual Basic.NET for Database Support
 

 
383
In order to get data from the database into the 
DataTable
object, the code calls the 
MyData.Fill()
method. Until the code calls this method, 
DS
contains all of the information about the Customers 
table, but none of the records.
Finally, the code calls the 
DS.FindByCustomerID()
method to find the record requested by the 
caller. The input argument to this method, 
Customer
, is a string that contains the 
CustomerID
field 
value. The output from the call is a 
NorthwindDataSet.CustomersRow
object, which is a special-
ized form of the 
DataRow
. Interestingly enough, IronPython can use the 
DataRow
directly without 
having to translate it in any way.
Accessing the database module through IronPython
The example extension has a method, 
GetData()
, that accepts a 
CustomerID
as input and provides 

NorthwindDataSet.CustomersRow
as output. All you need now is some IronPython code to make 
the request and display the result. Listing 17-6 shows a typical example.
LISTINg 17-6: 
 Displaying a record onscreen
# Import the Common Language Runtime.
import clr
# Access the extension.
clr.AddReferenceToFile(‘Northwind.DLL’)
import Northwind
# Create an instance of the Northwind access object.
MyData = Northwind.DBAccess()
# Fill a row with data.
Row = MyData.GetData(‘ALFKI’)
# Display the data on screen. 
print ‘All the data for Customer ID ALFKI’
print ‘\nCustomer ID: ‘, Row.CustomerID
print ‘Company Name: ‘, Row.CompanyName
print ‘Contact Name: ‘, 
if Row.IsContactNameNull():
print ‘Nothing’
else:
print Row.ContactName
print ‘Contact Title: ‘, 
if Row.IsContactTitleNull():
print ‘Nothing’
else:
print Row.ContactTitle
print ‘Address: ‘, 
if Row.IsAddressNull():
print ‘Nothing’
continues
548592c17.indd 383
2/24/10 12:49:39 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   389   390   391   392   393   394   395   396   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish