SEMESTER- V 5BCA1
–
DOT NET PROGRAMMING WITH VB.NET & ASP.NET Unit 5
Data Access with ADO.NET
Server Explorer:
Server Explorer ek tool hai jo aapko Visual Studio jaisi IDEs mein milta hai. Ye tool aapko servers aur unke resources ko easily manage karne aur explore karne mein madad karta hai, woh bhi IDE ke andar hi. Chalo iske kuch features ko thoda detail mein samajhte hain: 1. Database Management: Isme aap SQL Server jaise databases se connect kar sakte ho. Aap tables, views, stored procedures ko manage kar sakte ho aur queries bhi directly run kar sakte ho. Matlab aapko Visual Studio chhod kar alag tools mein jaane ki zaroorat nahi hai. 2. Server Connections: Iske through aap alag-alag servers, jaise application servers aur network resources se connect kar sakte ho. Development aur testing environments ko manage karna kaafi easy ho jata hai.
3. Azure Integration: Visual Studio ke Server Explorer se aap Azure resources (cloud wale) se bhi connect kar sakte ho. Aap cloud databases, storage aur web apps ko bhi easily manage kar sakte ho. 4. Services Management: Is tool se aap Windows services, event logs, aur system ke aur bhi components ko control aur manage kar sakte ho.
Data Adaptors and Datasets:
Data Adapters aur Datasets .NET applications mein data ko handle karne ke liye use hote hain, khas kar jab aapko databases ke saath kaam karna hota hai. Data Adapters (DataAdapter) DataAdapter ek bridge ki tarah kaam karta hai jo data ko Database se leke DataSet mein laane aur DataSet se wapas Database mein update karne mein madad karta hai. Ye connection-oriented nahi hota, matlab aapko continuously database se connect rehne ki zaroorat nahi hoti. - Data Fetching: DataAdapter ko use karke aap data ko Database se extract karke DataSet mein store kar sakte ho. Iska use "fill" method ke through hota hai jo DataSet ko fill karta hai data se. - Data Update: Jab aap DataSet mein data ko modify kar lete ho (add, update, delete), toh aap DataAdapter ki madad se database mein woh updates apply kar sakte ho.
Matlab ek tarah se DataAdapter aapko DataSet aur Database ke beech ek medium provide karta hai jisse aap data ko offline modify karke fir se database mein sync kar paate ho. DataSets DataSet ek in-memory representation hai jo database ke tables aur unke data ko store karta hai. Ye bilkul aise hai jaise aapke paas ek chhota sa temporary database memory mein bana hua ho. - Multiple Tables: DataSet ke andar aap multiple tables rakh sakte ho. Ye offline data access allow karta hai, matlab data ko ek baar load karke aap offline changes kar sakte ho bina database se connected rahe. - Disconnected Architecture: DataSet ek disconnected data model use karta hai. Matlab aapko data load karne ke baad database se connect rehne ki zaroorat nahi hoti. Aap saari changes DataSet mein kar sakte ho aur baad mein woh changes database mein sync kar sakte ho via DataAdapter. Kaise Kaam Karte Hain DataAdapter aur DataSet Saath Mein 1. Data Load: Pehle aap DataAdapter use karte ho jo DataSet mein data load karta hai, jaise ek query ko run karke tables ko fill karta hai. 2. Data Manipulation: DataSet mein load hone ke baad aap data ko modify, delete, ya add kar sakte ho. Ye sab kuch offline ho raha hota hai. 3. Update Database: Jab aap saari changes kar lete ho, toh fir se DataAdapter ka use karke aap DataSet ke data ko database mein update kar dete ho. Example: Maan lo aapko student records ko update karna hai. Pehle aap DataAdapter ka use karke records ko database se nikal ke DataSet mein load karte ho. Fir aap DataSet mein kuch
records ko update kar dete ho. Finally, aap DataAdapter ke through woh updated records database mein save karwa dete ho. Ye architecture kaafi useful hai jab aapko offline data editing ki zaroorat hoti hai ya jab aap baar-baar database ke saath connect hona avoid karna chahte ho efficiency ke liye.
ADO.NET Objects:
ADO.NET ek .NET framework ka part hai jiska use databases se connect hone, data access, aur manipulation ke liye kiya jata hai. ADO.NET me kuch important objects hain jo data ko handle karne me madad karte hain. Aayein in objects ko detail me samjhein: 1. Connection Object Connection object ka use database se connection establish karne ke liye hota hai. Ye ek tarah se bridge hai jo aapki application ko database se connect karta hai. - Common Classes: - SqlConnection: Ye SQL Server ke liye use hota hai. - OleDbConnection: Ye OLEDB compliant databases ke liye use hota hai (jaise MS Access). 2. Command Object