Visual Database Tools

Visual Studio નું Server Explorer database સાથે connect થાય છે, તેના tables ને browse કરે છે અને IDE ની બહાર ન નીકળ્યા વિના queries ને test કરે છે, અને connection string ને hand કરે છે જે તમારા code ને next lesson માં જોઈશે.

9 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

bills ને રાત survive કરવી જોઈએ

ShopKeeper એ અત્યાર સુધી જે કંઈ build કર્યું છે તે RAM માં lives કરે છે: app ને close કરો, અને day ના bills evaporate થાય છે. Mehta Uncle નું register book તમારા DataSet પર laughs કરે છે.

Unit 5 આને real database સાથે fix કરે છે: ShopDB, Bills table સાથે, exactly એવી જ thing જે તમે BCA205 માં build કર્યું હતું.

પણ database CODE ની એક પણ line લખતા પહેલા, professional database ને look કરે છે: કયા tables exist કરે છે? કયા columns? server even reachable છે કે નહીં? Visual Studio પાસે exactly એ reconnaissance માટે built-in tools છે.

Theory

tools, ઔપચારિક રીતે

આ paper માટે ત્રણ visual database tools matter કરે છે:

  • Server Explorer: IDE નું window databases પર: connections add કરો, tables ને expand કરો, rows ને view અને edit કરો, tables ને create કરો, બધું Visual Studio ની બહાર ન નીકળ્યા વિના
  • Query Designer: columns ને tick કરીને અને tables ને visually join કરીને SQL query build કરો, તેને run કરો, અને generated SQL ને read કરો (good BCA205 revision)
  • Data Sources window: table ને form પર drag કરો અને Visual Studio automatically bound grid ને generate કરે છે

તેઓ explore અને configure કરે છે; automation હજુ code ને belong કરે છે.

Follow along

ShopDB સાથે connecting, click by click

  1. View menu, Server Explorer panel usually Toolbox ની બાજુમાં ડાબી બાજુએ dock થાય છે.
  2. Data Connections પર right-click, Add Connection data source ને choose કરો: server database માટે Microsoft SQL Server, અથવા file-based માટે Microsoft Access database file (.mdb/.accdb).
  3. server અને database ને fill કરો (અથવા file પર browse કરો) local SQL Server માટે: server name . (dot) અને database ShopDB.
  4. Test Connection દબાવો reachability અને permissions ને verify કરે છે BEFORE તમે તેના પર depend કરો. problems ને અહીં fix કરો, code માં નહીં.
  5. નવા connection ને expand કરો Tables, પછી Bills: right-click, Show Table Data, અને rows IDE માં editable appear થાય છે.

Theory

dialog નું real output: connection string

તમે Add Connection dialog માં જે કંઈ typed કર્યું તે એક line of text માં compile થાય છે, connection string:

Data Source=.;Initial Catalog=ShopDB;Integrated Security=True

Data Source server ને names કરે છે (dot એટલે આ machine), Initial Catalog database, Integrated Security Windows user તરીકે login કરે છે. Server Explorer માં connection ને select કરો અને તેના Properties pane string ને show કરે છે, copy કરવા ready.

તેને keep કરો: next lesson ના ADO.NET objects exactly આ string ને તેમના first ingredient તરીકે demand કરે છે.

Quiz

Add Connection dialog માં Test Connection button actually શું verify કરે છે?

  1. તમારા SQL queries syntax errors થી free છે
  2. કે server અને database given credentials સાથે reachable છે, right now
  3. કે Bills table valid data ધરાવે છે
  4. કે ADO.NET customer ની machine પર installed છે
Show the answer

કે server અને database given credentials સાથે reachable છે, right now

Test Connection એક live handshake perform કરે છે: શું આ machine, આ credentials સાથે, આ moment પર આ database ને open કરી શકે છે? Reachability અને login, nothing more. તે કોઈ tables ને read નથી કરતું (option C) અને કોઈ queries ને જાણતું નથી જે તમે later લખશો (option A): SQL mistakes હજુ code માં તમારી wait કરે છે. Option D target machine ને તમારી own સાથે confuse કરે છે; ADO.NET anyway .NET સાથે ship થાય છે. habit જે તે build કરે છે એ point છે: કંઈ pump કરતા પહેલા pipe ને prove કરો કે work કરે છે.

Think first

Tools અથવા code? 3 jobs પર rule કરો

ત્રણ jobs: (1) check કરો કે શું yesterday ના bills actually Bills table માં પહોંચ્યા, (2) દરેક new bill ને automatically save કરો જ્યારે cashier Print પર click કરે, (3) SUM query ને trust કરતા પહેલા try out કરો. દરેક ને visual tools અથવા ADO.NET code assign કરો, tap કરતા પહેલા.

Show the answer

(1) Tools: Server Explorer, Show Table Data: 10-second eyeball, કોઈ code deserved નહીં. (3) Tools: Query Designer SUM ને interactively run કરે છે જ્યાં સુધી તે right ન થાય; પછી proven SQL code માં moves થાય છે. (2) Code: ફક્ત ShopKeeper ની અંદર running ADO.NET click-time પર automatically act કરી શકે છે; કોઈ IDE window till સાથે ship નથી થતું. division જે યાદ રાખવા: tools exploring, verifying અને prototyping માટે; code anything માટે જે APPLICATION એ પોતે by itself કરવું જોઈએ, જે next lesson નો whole business છે.

Watch out

જ્યાં demo dies થાય છે

live data ને casually editing: Show Table Data REAL database ને edit કરે છે જેમ તમે type કરો: તમારા laptop પર ShopDB માં fine, production shop ના data માં catastrophic. કયા connection ને touch કરો છો તે જાણો.

connection strings ને memory થી hand-typing કરવા: one misspelled Catalog અને કંઈ connect નથી; tested connection ના Properties pane થી copy કરો instead.

tools ને assume કરવા કે app સાથે travel કરે છે: તેઓ Visual Studio features છે; deployed ShopKeeper પાસે ફક્ત તમારું code અને string છે.

Theory

Reconnaissance done

તમે હવે battlefield ને see કરી શકો છો: ShopDB reachable (tested), Bills table browsable, working connection string copied અને waiting. બાકી રહે છે SHOPKEEPER ને teach કરવું કે run time પર શું તમે just by hand કર્યું: connection ને open કરો, BCA205 ના SQL ને send કરો, results ને home carry કરો. એ machinery, 5 objects exactly એક job સાથે દરેક, એ ADO.NET object model છે: next lesson, અને આ subject ની last new architecture.

Summary

Key takeaways

  • Server Explorer Visual Studio ની અંદર databases સાથે connect થાય છે અને browse કરે છે: tables, data, even table creation.
  • Add Connection: provider choose કરો (SQL Server અથવા Access file), server અને database ને name કરો, પછી ALWAYS Test Connection.
  • Query Designer SQL ને visually build અને test-run કરે છે; Data Sources tables ને bound grids માં drag કરે છે.
  • dialog નું true product એ connection string છે: Data Source, Initial Catalog, security settings.
  • Tools explore, verify અને prototype કરે છે; ADO.NET code automate કરે છે: બંને, તે order માં.
  • Show Table Data real database ને edit કરે છે: connection ને respect કરો જે તમે પર છો.
  • Memory hook: pump કરતા પહેલા pipe ને test કરો.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Database access using ADO.NET

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Visual Database Tools · .NET Programming · Gri-Learn