UNIT - III BUILDING WINDOWS APPLICATION GENERAL WINDOWS CONTROLS FOR THE WINDOWS APPLICATION

Size: px
Start display at page:

Download "UNIT - III BUILDING WINDOWS APPLICATION GENERAL WINDOWS CONTROLS FOR THE WINDOWS APPLICATION"

Transcription

1 UNIT - III BUILDING WINDOWS APPLICATION GENERAL WINDOWS CONTROLS FOR THE WINDOWS APPLICATION 1

2 SLNO CONTROL NAME SLNO CONTROL NAME 1. Button 9. PictureBox 2. Checkbox 3. RadioButton 4. Label 5. Textbox 6. ComboBox 7. ListBox 10. Progressbar 11. Treeview 12. DataGridView 13. ToolTip 8. ListView 14. Timer WINDOWS COMMON CONTROL PROPERTIES 2

3 SLNO PROPERITE PROPERTY VALUE DESCRIPTION NAME 1. Name Form1 Indicates the name used in code to identify the object or control 2. Autosize True or False Specifies whether a control will automatically size iteselft to fit its contents 3. BackColor Color Name The background color of the component 4. BackgroundImage Image File path The background image used for the control 5. Enabled True or False Indicates whether the control is enabled 6. ForeColor Color Name The foreground color of this component, which is used to display text. 7. Font Font Face, Font Style, Font size, The font used to display text in the control. Font Color 8. Location X, Y axis The coordinates of the upper left corner of the control relative to the upper left corner of its container 9. Locked True or False The Locked property determines if we can move or resize the control 10. Size Width and Height The size of the control in pixels 11. Text Text of the Particular Control The text associated with the control 12. Visible True or False Determines whether the control is visible or hidden 13. TabIndex Index value to the control Determines the index in the TAB order that this control will occupy. 14. TabStop True or False Indicates whether the user can use the TAB key to give focus to the control. 15. TextAlign Left, Center, Rigth The alignment of the text that will be displayed on the control. 16. ToolTip Text Tool Tip Text on the Control Determines the tool tip shown when the mouse hovers over the control. 17. UseMnemonic True or False If true, the first character proceeded by an ampersand (&) will be used as the button s mnemonic key. WINDOWS COMMON CONTROLS DEFAULT EVENT HANDLERS 3

4 SLNO CONTROLS HOW TO ADD THE DATA S TO DEFAULT EVENT HANDLER CONTROL 1. Form Form1.Text = Chettinad ; private void Form1_Load(object sender, EventArgs e) 2. Button Button1.Text= Click Here ; private void button1_click(object sender, EventArgs e) Label Label.Text= Enter the A Value ; private void label1_click(object sender, EventArgs e) 3. Textbox Textbox1.Text= Insert the Text Here ; private void textbox1_textchanged(object sender, EventArgs e) 4. Checkbox Checkbox1.Text= Addition ; private void checkbox1_checkedchanged(object sender, EventArgs e) 5. Radiobutton Radiobutton1.Text= Addition ; private void radiobutton1_checkedchanged(object sender, EventArgs e) 6. CheckListBox CheckListbox.Items.add( Add ); CheckLIstbox.Items.add( Sub ); private void checkedlistbox1_selectedindexchanged(object sender, EventArgs e) 7. ComboBox Combobox.Items.add( Add ); private void combobox1_selectedindexchanged(object sender, EventArgs e) Combobox.Items.add( Sub ); 8. ListBox Listbox1.Items.add( Add ); Listbox1.Items.add( Sub ); private void listbox1_selectedindexchanged(object sender, EventArgs e) 9. Picturebox Picturebox1.Load( Picture File Path ) private void picturebox1_click(object sender, EventArgs e) 10. Progressbar NIL private void progressbar1_click(object sender, EventArgs e) 11. Treeview Treeview1.Items.add( Add ); private void treeview1_afterselect(object sender, TreeViewEventArgs e) TreeView1.Items.add( Sub ); 12. Listview Listview1.Items.add( Add ); private void listview1_selectedindexchanged(object sender, EventArgs e) Listview1.Items.add( Sub ); 13. Groupbox Groupbox1.Controls.add(button1); private void groupbox1_enter(object sender, EventArgs e) 14. Timer Nil private void timer1_tick(object sender, EventArgs e) EXTRA PROPERTIES FOR THE WINDOWS CONTROLS 4

5 SLN CONTROL PROPERITE PROPERTY VALUE DESCRIPTION O NAME NAME 1. PictureBox Image.jpg or.bmp or.gif The image display in the PictureBox. WaitOnLoad True or False Controls whether processing will stop until the image is loaded. 2. RadioButton Checked True or False Indicates whether the component is in the checked state Checkbox TextBox Checked True or False Indicates whether the component is in the checked state. CheckState Unchecked or Checked Indicates the state of the component. or Intermediate ThreeState True or False Indicates whether the CheckBox will allow three check states rather than two. HideSelection True or False Indicates that the selection should be hidden when the edit control loses focus. MaxLength Specifies the maximum number of character that can be entered into the edit control. Multiline True or False Controls whether the text of the edit control can span more than one line. PasswordChar ***** or &&&&& Indicates the character to display for password input for single line edit controls. ScrollBars None, Horizontal, Vertical Indicates, for multiline edit contrls, which scroll bars, will be shown for this control. WordWrap True or False Indicates if lines are automatically word wrapped for multiline edit controls. ShortcutsEnabled True or False Indicates whether shortcuts defined for the control are enabled. 5. ControlBox True or False Determines whether a form has a Control / System menu box. Cursor Different Cursor Control The Cursor that appear when the pointer moves over the control. Form MaximizeBox True or False Determines whether a form has a maximize box in the upper right corner of its caption bar. MinimizeBox True or False Determines whether a form has a minimize box in the upper right corner of its caption bar. StartPosition Windows appears for the Determines the position of a form when it first appears. different location WindowState Normal, Maximize, Determines the position of a form when it first appears. Minimize 6. Timer Enabled True or False Enables generation of Elapsed events Interval 1000 (milliseconds) The frequency of Elapsed events in milliseconds 7. ProgressBar Minimum 0 The lower bound of the range this ProgressBar is working with. Maximum 1000 The upper bound of the range this ProgressBar is working with. MessageBox Program using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Form1 : Form public Form1() InitializeComponent(); 5

6 private void button1_click(object sender, EventArgs e) MessageBox.Show("Welcome to Chettinad College of Engineering and Technology"); private void button2_click(object sender, EventArgs e) MessageBox.Show("Welcome", "Chettinad", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); private void button3_click(object sender, EventArgs e) DialogResult ans = MessageBox.Show("Arithmetic Operation", "Welcome", MessageBoxButtons.OKCancel); if (ans == DialogResult.OK ) MessageBox.Show("Click OK Button"); else if(ans == DialogResult.Cancel) MessageBox.Show("Click Cancel Button"); private void button4_click(object sender, EventArgs e) Button_Control f2 = new Button_Control(); f2.show(); Addition of Two Numbers using Button, Label and Textbox using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Button_Control : Form public Button_Control() InitializeComponent(); private void button1_click(object sender, EventArgs e) int a, b, c; a = int.parse(textbox1.text); b = int.parse(textbox2.text); c = a + b; 6

7 Arithmetic Operation using Checkboxes private void checkbox1_checkedchanged(object sender, EventArgs e) if (checkbox1.checked == true) checkbox2.checked = false; checkbox3.checked = false; checkbox4.checked = false; checkbox5.checked = false; x = textbox1.text; y = textbox2.text; namespace WindowsApplication1 public partial class CheckBox_Control : Form public CheckBox_Control() InitializeComponent(); a = int.parse (x); b = int.parse(y); c = a + b; int a, b, c; string x, y; private void checkbox2_checkedchanged(object sender, EventArgs e) if (checkbox2.checked == true) checkbox1.checked = false; checkbox3.checked = false; checkbox4.checked = false; checkbox5.checked = false; x = textbox1.text; y = textbox2.text; a = int.parse(x); b = int.parse(y); c = a - b; private void checkbox3_checkedchanged(object sender, EventArgs e) if (checkbox3.checked == true) checkbox1.checked = false; checkbox2.checked = false; checkbox4.checked = false; checkbox5.checked = false; x = textbox1.text; y = textbox2.text; a = int.parse(x); b = int.parse(y); c = a * b; 7

8 private void checkbox4_checkedchanged(object sender, EventArgs e) if (checkbox4.checked == true) checkbox1.checked = false; checkbox2.checked = false; checkbox3.checked = false; checkbox5.checked = false; private void checkbox5_checkedchanged(object sender, EventArgs e) if (checkbox5.checked == true) checkbox1.checked = false; checkbox2.checked = false; checkbox3.checked = false; checkbox4.checked = false; x = textbox1.text; y = textbox2.text; a = int.parse(x); b = int.parse(y); c = a / b; textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; Arithmetic Operation using Radio Buttons private void radiobutton1_checkedchanged(object sender, EventArgs e) if (radiobutton1.checked == true) radiobutton2.checked = false; radiobutton3.checked = false; radiobutton4.checked = false; radiobutton5.checked = false; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Radio_Control : Form int a, b, c; public Radio_Control() InitializeComponent(); try a = int.parse(textbox1.text); b = int.parse(textbox2.text); catch c = a + b; 8

9 private void radiobutton2_checkedchanged(object sender, EventArgs e) if (radiobutton2.checked == true) radiobutton1.checked = false; radiobutton3.checked = false; radiobutton4.checked = false; radiobutton5.checked = false; a = int.parse(textbox1.text); b = int.parse(textbox2.text); c = a - b; private void radiobutton3_checkedchanged(object sender, EventArgs e) if (radiobutton3.checked == true) radiobutton1.checked = false; radiobutton2.checked = false; radiobutton4.checked = false; radiobutton5.checked = false; a = int.parse(textbox1.text); b = int.parse(textbox2.text); c = a * b; private void radiobutton4_checkedchanged(object sender, EventArgs e) if (radiobutton4.checked == true) radiobutton1.checked = false; radiobutton2.checked = false; radiobutton3.checked = false; radiobutton5.checked = false; a = int.parse(textbox1.text); b = int.parse(textbox2.text); private void radiobutton5_checkedchanged(object sender, EventArgs e) if (radiobutton5.checked == true) radiobutton1.checked = false; radiobutton2.checked = false; radiobutton3.checked = false; radiobutton4.checked = false; textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; c = a / b; private void Form6_Load(object sender, EventArgs e) radiobutton1.checked = false; radiobutton2.checked = false; radiobutton3.checked = false; radiobutton4.checked = false; radiobutton5.checked = false; 9

10 Arithmetic Operation using ComboBox and ListBox private void Form5_Load(object sender, EventArgs e) combobox1.items.add("addition"); combobox1.items.add("subtraction"); combobox1.items.add("multiplication"); combobox1.items.add("division"); combobox1.items.add("clear"); using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; listbox1.items.add("addition"); listbox1.items.add("subtraction"); listbox1.items.add("multiplication"); listbox1.items.add("division"); listbox1.items.add("clear"); namespace WindowsApplication1 public partial class Form5 : Form int a, b, c; public Form5() InitializeComponent(); private void combobox1_selectedindexchanged(object sender, EventArgs e) a = int.parse(textbox1.text); b = int.parse(textbox2.text); if (combobox1.selectedindex == 0) c = a + b; if (combobox1.selectedindex == 1) c = a - b; if (combobox1.selectedindex == 2) c = a * b; if (combobox1.selectedindex == 3) c = a / b; if (combobox1.selectedindex == 4) textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; private void listbox1_selectedindexchanged(object sender, EventArgs e) a = int.parse(textbox1.text); b = int.parse(textbox2.text); if (listbox1.selectedindex == 0) c = a + b; if (listbox1.selectedindex == 1) c = a - b; if (listbox1.selectedindex == 2) c = a * b; if (listbox1.selectedindex == 3) c = a / b; if (listbox1.selectedindex == 4) textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; 10

11 Arithmetic Operation using CheckListBox private void Checkboxlist_Control_Load(object sender, EventArgs e) checkedlistbox1.items.add("addition"); checkedlistbox1.items.add("subtraction"); checkedlistbox1.items.add("multiplication"); checkedlistbox1.items.add("division"); checkedlistbox1.items.add("clear"); using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Checkboxlist_Control : Form public Checkboxlist_Control() InitializeComponent(); int a, b, c; private void checkedlistbox1_selectedindexchanged(object sender, EventArgs e) a = int.parse (textbox1.text ); b = int.parse (textbox2.text ); if (checkedlistbox1.selectedindex == 0) c = a + b; if (checkedlistbox1.selectedindex == 1) c = a - b; if (checkedlistbox1.selectedindex == 2) c = a * b; if (checkedlistbox1.selectedindex == 3) c = a / b; if (checkedlistbox1.selectedindex == 4) textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; 11

12 Program for the PictureBox using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Picturebox_Control : Form public Picturebox_Control() InitializeComponent(); picturebox1.load(@"c:\documents and Settings\All Users\Documents\My Pictures\Sample Pictures\sunset.jpg"); private void button1_click(object sender, EventArgs e) picturebox1.image = Image.FromFile (@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\sunset.jpg"); picturebox1.imagelocation = " Program for the ProgressBar private void Progress_Control_Load(object sender, EventArgs e) progressbar1.minimum = 0; progressbar1.maximum = 1000; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Progress_Control : Form public Progress_Control() InitializeComponent(); e) private void button1_click(object sender, EventArgs progressbar1.increment(10); 12

13 Program for the ProgressBar and Timer Control private void Timer_Control_Load(object sender, EventArgs e) progressbar1.minimum = 0; progressbar1.maximum = 1000; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Timer_Control : Form public Timer_Control() InitializeComponent(); private void timer1_tick(object sender, EventArgs e) progressbar1.increment(100); NOTE In the Timer Control Properties change the Enabled properties is True and the set the Time Interval ( not Zero) Program for the ListView private void button1_click(object sender, EventArgs e) listview1.view = View.LargeIcon; private void button2_click(object sender, EventArgs e) listview1.view = View.SmallIcon; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Listview_Control : Form public Listview_Control() InitializeComponent(); private void button3_click(object sender, EventArgs e) listview1.view = View.List; private void button4_click(object sender, EventArgs e) listview1.view = View.Details; private void button5_click(object sender, EventArgs e) listview1.clear(); 13

14 Addition of Two Number using the Code File (Creating your Own User Interface) using System; using System.Data; using System.Drawing; using System.Windows.Forms; public class Own : Form Button b1; Label l1, l2, l3; TextBox t1, t2, t3; int a, b, c; public Own() l1 = new System.Windows.Forms.Label(); l1.location = new System.Drawing.Point(0,0); l1.size = new System.Drawing.Size(130,25); l1.text = "Enter the A Value"; Controls.Add(l1); t1 = new System.Windows.Forms.TextBox (); t1.location = new System.Drawing.Point(150,0); t1.size = new System.Drawing.Size(50,25); t1.text = ""; Controls.Add(t1); l2 = new System.Windows.Forms.Label(); l2.location = new System.Drawing.Point(0,50); l2.size = new System.Drawing.Size(130,25); l2.text = "Enter the B Value"; Controls.Add(l2); t2 = new System.Windows.Forms.TextBox(); t2.location = new System.Drawing.Point(150,50); t2.size = new System.Drawing.Size(50,25); t2.text = ""; Controls.Add(t2); l3 = new System.Windows.Forms.Label(); l3.location = new System.Drawing.Point(0,100); l3.size = new System.Drawing.Size(150,25); l3.text = "Addition of the Two Numbers"; Controls.Add(l3); t3 = new System.Windows.Forms.TextBox (); t3.location = new System.Drawing.Point(160,50); t3.size = new System.Drawing.Size(50,25); t3.text = "Enter the A Value"; Controls.Add(t3); class Main_Own static void Main() Application.Run(new Own()); b1 = new System.Windows.Forms.Button(); b1.location = new System.Drawing.Point(200,200); b1.size = new System.Drawing.Size(100, 25); b1.text = "Click Addition"; b1.click += new System.EventHandler(b1_Click); Controls.Add(b1); public void b1_click(object sender, EventArgs ea) a = int.parse(t1.text); b = int.parse(t2.text); c = a + b; t3.text = c.tostring(); 14

15 Output of the Above program is Creating Calculator Program using the Code File (Creating your Own User Interface) //1. Include the Namespaces// using System; using System.Drawing; using System.Windows.Forms; //2. Create a class that inherit from Form class of Windows// public class ButtonDemo: Form b7; //3.Create the Controls // Button b0; Button b1; Button b2; Button b3; Button b4; Button b5; Button b6; Button String s1=""; String s2=""; String op=""; TextBox t1; //4.Create the class Constructor methosd to invoke the components to be initialized// public ButtonDemo() //5. Invoke the method to initialize the components// InitializeComponent(); 15

16 private void InitializeComponent() // Initilaize the components properties and Events// t1=new TextBox(); t1.name="textbox1"; t1.location=new Point(50,80); t1.size=new System.Drawing.Size(80,50); this.controls.add(t1); b0=new Button(); b0.location=new Point(50,120); b0.size=new System.Drawing.Size(25,25); b0.text="0"; b0.click+=new System.EventHandler(this.btnsubmit_Click); this.controls.add(b0); b1=new Button(); b1.location=new Point(75,120); b1.size=new System.Drawing.Size(25,25); b1.text="1"; b1.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b1); b2 = new Button(); b2.location = new Point(100, 120); b2.size = new System.Drawing.Size(25, 25); b2.text = "2"; b2.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b2); b3 = new Button(); b3.location = new Point(125, 120); b3.size = new System.Drawing.Size(25, 25); b3.text = "3"; b3.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b3); b4 = new Button(); b4.location = new Point(50, 145); b4.size = new System.Drawing.Size(25, 25); b4.text = "4"; b4.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b4); b5 = new Button(); b5.location = new Point(75, 145); b5.size = new System.Drawing.Size(25, 25); b5.text = "+"; b5.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b5); b6 = new Button(); b6.location = new Point(100, 145); b6.size = new System.Drawing.Size(25, 25); b6.text = "-"; b6.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b6); b7 = new Button(); b7.location = new Point(125, 145); b7.size = new System.Drawing.Size(25, 25); b7.text = "="; b7.click += new System.EventHandler(this.btnsubmit_Click); this.controls.add(b7); this.name="button Demo"; this.text="button Demo"; 16

17 //Events handling Procedures// private void btnsubmit_click(object sender, EventArgs e) if(sender.equals(b0)) t1.text += "0"; else if (sender.equals(b1)) t1.text += "1"; else if (sender.equals(b2)) t1.text+="2"; else if (sender.equals(b3)) t1.text += "3"; else if (sender.equals(b4)) t1.text += "4"; else if (sender.equals(b5)) s1=t1.text; t1.text=""; op=b5.text; else if(sender.equals(b7)) if(op.equals("+")) MessageBox.Show((Int32.Parse(t1.Text)+Int32.Parse(s1)).ToString()); public class Demo static void Main() System.Windows.Forms.Application.Run(new ButtonDemo()); Output of the Above program is 17

18 Data Access with ADO.NET What Is ADO.NET? 1. ADO.NET is a collection of classes, interfaces, structures, and enumerated types that manage data access from relational data stores within the.net Framework 2. These collections are organized into namespaces: System.Data, System.Data.OleDb, System.Data.SqlClient, etc. 3. ADO.NET is an evolution from ADO. 4. Does not share the same object model, but shares many of the same paradigms and functionality! 5. Designed for distributed and Web applications 6. Provides 2 models for data access Connection Oriented Connectionless 18

19 Benefits of ADO.NET 1. Interoperability through use of XML * Open standard for data that describes itself * Human readable and decipherable text * Used internally but accessible externally Can use XML to read and write and move data 2. Scalability through the disconnected DataSet * Connections are not maintained for long periods * Database locking does not occur Locking support with ServiceComponents Optimistic locking otherwise * Works the way the Web works: Hit and Run! 3. Maintainability * Separation of data logic and user interface Idea of Universal Data Access Connection of (object-oriented) programming languages and relational data bases Uniform programming model and API Special implementations for data sources (providers) 19

20 Data Providers Microsoft s layered architecture for data access ADO.Net Providers Provider Name ODBC Data Provider OleDb Data Provider API prefix Odbc OleDb Data Source Description Data Sources with an ODBC interface. Normally older data bases. Data Sources that expose an OleDb interface, i.e. Access or Excel. Oracle Data Provider Oracle For Oracle Databases. SQL Data Provider Sql For interacting with Microsoft SQL Server. Borland Data Provider Bdp Generic access to many databases such as Interbase, SQL Server, IBM DB2, and Oracle. 20

21 History of Universal Data Access (Microsoft) ODBC OLE DB ADO (ActiveX Data Objects) ADO.NET ADO connection-oriented sequential access only one table supported COM-marshalling ADO.NET connection-oriented + connectionless sequential access + main-memory representation with direct access more than one table supported XML-marshalling DIFFERENCES BETWEEN ADO AND ADO.NET ADO ADO.NET ADO has one main object that is used to reference data, called the Record set object. This object basically gives you a single table view of your data, although you can join tables to create a new set of records. ADO works with connected data. This means that when you access data, such as viewing and updating data, it is real-time, with a connection being used all the time. This is barring, of course, you programming special routines to pull all your data into temporary tables. With ADO.NET, you have various objects that allow you to access data in various ways. The Dataset object will actually allow you to store the relational model of your database. This allows you to pull up customers and their orders, accessing/updating the data in each related table individually. ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy of the data using XML. ADO.NET only holds the connection open long enough to either pull down the data or to make any requested updates. This makes ADO.NET efficient to use for Web applications. It's also decent for desktop applications. In ado user can move sequentially to database In ado.net user can move one data from one table to another table. ADO allows you to create client-side cursors only ADO allows you to persist records in XML format COM marshalling ADO.NET we don't have any cursor support in ADO.NET. ADO.NET allows you to manipulate your data using XML as the primary means. This is nice when you are working with other business applications and also helps when you are working with firewalls because data is passed as HTML and XML. XML marshalling 21

22 Architecture of ADO.NET ADO.NET Objects The SqlConnection Object To interact with a database, you must have a connection to it. The connection helps identify the database server, the database name, user name, password, and other parameters that are required for connecting to the data base. A connection object is used by command objects so they will know which database to execute the command on. The SqlCommand Object The process of interacting with a database means that you must specify the actions you want to occur. This is done with a command object. You use a command object to send SQL statements to the database. A command object uses a connection object to figure out which database to communicate with. You can use a command object alone, to execute a command directly, or assign a reference to a command object to an SqlDataAdapter, which holds a set of commands that work on a group of data as described below. The SqlDataReader Object Many data operations require that you only get a stream of data for reading. The data reader object allows you to obtain the results of a SELECT statement from a command object. For performance reasons, the data returned from a data reader is a fast forward-only stream of data. This means that you can only pull the data from the stream in a sequential manner This is good for speed, but if you need to manipulate data, then a DataSet is a better object to work with. 22

23 The DataSet Object DataSet objects are in-memory representations of data. They contain multiple Datatable objects, which contain columns and rows, just like normal database tables. You can even define relations between tables to create parent-child relationships. The DataSet is specifically designed to help manage data in memory and to support disconnected operations on data, when such a scenario make sense. The DataSet is an object that is used by all of the Data Providers, which is why it does not have a Data Provider specific prefix. The SqlDataAdapter Object Sometimes the data you work with is primarily read-only and you rarely need to make changes to the underlying data source Some situations also call for caching data in memory to minimize the number of database calls for data that does not change. The data adapter makes it easy for you to accomplish these things by helping to manage data in a disconnected mode. The data adapter fills a DataSet object when reading the data and writes in a single batch when persisting changes back to the database. A data adapter contains a reference to the connection object and opens and closes the connection automatically when reading from or writing to the database. Additionally, the data adapter contains command object references for SELECT, INSERT, UPDATE, and DELETE operations on the data. You will have a data adapter defined for each table in a DataSet and it will take care of all communication with the database for you. All you need to do is tell the data adapter when to load from or write to the database. DataTables and DataColumns The DataTable has a number of public properties, including the columns collection, which returns the DataColumnCollectionobject,which in trun consists of DataColumn objects. Each DataColumn object represents a column in a table DataRelations DataRelation represents a relationship between two tables through DataColumn objects. For example, in the Northwind database the Customers table is in a relationship with the Orders table through the CustomerID column DataRows DataTable s Rows collection returns a set of rows for that table. Use this collection to examine the results of queries against the database, iterating throught the rows to examine each record in trun. 23

24 Connection-oriented versus Connectionless Connection Oriented Keeps the connection to the data base alive Always up-to-date data Intended for applications with: short running transactions only a few parallel access operations Connectionless Oriented No permanent connection to the data source Data cached in main memory Changes in main memory may be in conflict with changes in data source Intended for applications with: many parallel and long lasting access operations (e.g.: Web applications) Data Bound Controls The General categories for the Data Bound Controls is classified into two types: 1. Simple Data Bound Controls 2. Complex Data Bound Controls 1. Simple Data Bound Controls 1. Label Box 2. Text Box 2. Complex Data Bound Controls 1. Combo Box 2. List Box 3. DataGridView 24

25 IDbConnection: Property ConnectionString ExecuteNonQuery Method ExecuteScalar Method 25

26 2 Transaction models ADO.NET and Transactions 1) Local transactions: transactions for one connection provided by ADO.NET 2) Distributed transactions: transactions for several connections usage of Microsoft Distributed Transaction Component (MSDTC) namespace System.Transaction DATABASE PROGRAMS 26

27 WINDOWS AUTHENTICATION using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 public partial class Form2 : Form public OleDbCommand com; public OleDbConnection con; public OleDbDataAdapter adp; public OleDbDataReader rs; public Form2() InitializeComponent(); con = new OleDbConnection(); con.connectionstring = "provider=microsoft.jet.oledb.4.0; " + "data source = z:\\csharp\\stud.mdb"; con.open(); com = new OleDbCommand(); com.connection = con; adp = new OleDbDataAdapter(com); MessageBox.Show("Connectioin Sucessfully"); 27

28 private void button1_click(object sender, EventArgs e) string s1 = "", s2 = ""; try com.commandtext = "select * from MARK"; rs = com.executereader(); if (rs.read()) s1 = rs.getvalue(0).tostring(); s2 = rs.getvalue(1).tostring(); if (textbox1.text.equals(s1) && textbox2.text.equals(s2)) Form1 f1 = new Form1(); f1.show(); else MessageBox.Show("Invalid User Name and Password"); catch MessageBox.Show("Runtime error in the Select"); private void button2_click(object sender, EventArgs e) this.close(); 28

29 Access the Data in the Access Database using the OLEDB Access (List Box) private void Form1_Load(object sender, EventArgs e) string connectionstring = "provider=microsoft.jet.oledb.4.0; " + "data source = z:\\c#\\data_connect\\data_connect\\mark.mdb"; string commandstring = "Select SLNO, NAME from Stud"; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Data_Connect public partial class OLEDBAccess : Form public OLEDBAccess() InitializeComponent(); OleDbConnection conn= new OleDbConnection(connectionstring); OleDbDataAdapter DataAdapter = new OleDbDataAdapter(commandstring, conn); DataSet DataSet = new DataSet(); DataAdapter.Fill(DataSet, "Stud"); DataTable datatable = DataSet.Tables[0]; foreach (DataRow datarow in datatable.rows) listbox1.items.add(datarow["slno"].tostring() + " " + datarow["name"].tostring() ); The Output of the Above Program is 29

30 Access the Data in the Access Database using the OLEDB Access (DataGridView) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Data_Connect public partial class OLEDB_Grid : Form private System.Data.OleDb.OleDbConnection myconnection; private System.Data.DataSet mydataset; private System.Data.OleDb.OleDbCommand mycommand; private System.Data.OleDb.OleDbDataAdapter DataAdapter; public OLEDB_Grid() InitializeComponent(); string connectionstring = "provider=microsoft.jet.oledb.4.0; " + "data source = z:\\c#\\data_connect\\data_connect\\mark.mdb"; myconnection = new System.Data.OleDb.OleDbConnection(connectionString); myconnection.open(); mycommand = new System.Data.OleDb.OleDbCommand(); mycommand.connection = myconnection; mycommand.commandtext = "Select * from stud"; DataAdapter = new System.Data.OleDb.OleDbDataAdapter(); DataAdapter.SelectCommand = mycommand; mydataset = new System.Data.DataSet(); DataAdapter.TableMappings.Add("Table", "Stud"); DataAdapter.Fill(myDataset); datagridview1.datasource = mydataset.tables["stud"].defaultview; 30

31 The Output of the Above Program is Access the Data in the Access Database using the OLEDB Providers (Using Insert, Select, Update and Delete) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Text; using System.Windows.Forms; 31

32 namespace Data_Connect public partial class OLEDB_Insert : Form public OleDbConnection con; public OleDbCommand com; public OleDbDataAdapter adp; public OleDbDataReader rs; public OLEDB_Insert() InitializeComponent(); con = new OleDbConnection(); con.connectionstring = "provider=microsoft.jet.oledb.4.0; " + "data source = z:\\c#\\data_connect\\data_connect\\mark.mdb"; con.open(); com = new OleDbCommand(); com.connection = con; adp = new OleDbDataAdapter(com); MessageBox.Show("Connectioin Sucessfully"); Insert Command private void Inserted_Click(object sender, EventArgs e) try com.commandtext = "insert into STUD values(?,?)"; adp.insertcommand = com; adp.insertcommand.parameters.add("slno", textbox1.text); adp.insertcommand.parameters.add("name", textbox2.text); adp.insertcommand.executenonquery(); MessageBox.Show("Records are Inserted Successfully"); catch MessageBox.Show("Runtime Error at Inserted"); 32

33 Select Command private void Selected_Click(object sender, EventArgs e) try com.commandtext = "select * from STUD where SLNO=?"; com.parameters.add("slno", textbox1.text); rs = com.executereader(); if (rs.read()) textbox1.text = rs.getvalue(0).tostring(); textbox2.text = rs.getvalue(1).tostring(); MessageBox.Show("Selected from the Table Successfully"); catch MessageBox.Show("Runtime error in the Select"); Update Command private void Updated_Click(object sender, EventArgs e) try com.commandtext = "select * from STUD where SLNO=?"; com.parameters.add("slno", textbox1.text); rs = com.executereader(); if (rs.read()) textbox1.text = rs.getvalue(0).tostring(); textbox2.text = rs.getvalue(1).tostring(); MessageBox.Show("Selected from the Table Successfully"); com.commandtext = "update STUD set SLNO=?,NAME=? where SLNO=?"; com.parameters.add("slno", textbox1.text); com.parameters.add("name", textbox2.text); com.executenonquery(); MessageBox.Show("Records Updated Successfully"); catch MessageBox.Show("Runtime error at the Update"); 33

34 Delete Command private void Deleted_Click(object sender, EventArgs e) try com.commandtext = "delete from STUD where SLNO=?"; com.parameters.add("slno", textbox1.text); com.executenonquery(); MessageBox.Show("Record Deleted Successfully"); catch MessageBox.Show("Runtime error at Deleted"); Clear Command private void Clear_Data_Click(object sender, EventArgs e) textbox1.text = ""; textbox2.text = ""; The Output of the Above Program is 34

35 Data Access through Microsoft SQL Server Provider using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace DatabaseDemo public partial class Form1 : Form public Form1() InitializeComponent(); string constr = "Data Source=(local);Initial Catalog=DemoDB;Integrated Security=True"; SqlConnection con = null; SqlCommand cmd = null; SqlDataReader dr; string str; DataSet ds = new DataSet(); SqlDataAdapter sad; 35

36 private void Form1_Load(object sender, EventArgs e) ds.clear(); try con = new SqlConnection(constr); con.open(); str = "select * from tbuserinfo"; sad = new SqlDataAdapter(str, con); sad.fill(ds, "tbuserinfo"); if (ds.tables[0].rows.count > 0) DataGrid1.DataSource = ds; DataGrid1.SetDataBinding(ds, "tbuserinfo"); else MessageBox.Show("Sorry!\n Search Result Not Found.\n Please try again."); catch (Exception ex) MessageBox.Show(ex.Message.ToString()); private void button1_click(object sender, EventArgs e) if (TextBox1.Text.Equals("") && TextBox2.Text.Equals("") && TextBox3.Text.Equals("")) MessageBox.Show("Input datas are cannot be empty"); else try con = new SqlConnection(constr); con.open(); str = "Insert into tbuserinfo Values(" + TextBox1.Text.ToString().Trim() + ","; str = str + "'" + TextBox2.Text.ToString().Trim() + "',"; str = str + "'" + TextBox3.Text.ToString().Trim() + "')"; cmd = new SqlCommand(str, con); cmd.executenonquery(); MessageBox.Show("Successfully Added"); cmd.dispose(); con.close(); catch (Exception ex) MessageBox.Show(ex.Message.ToString()); 36

37 private void button2_click(object sender, EventArgs e) if (TextBox1.Text.Equals("")) MessageBox.Show("Search Input Cannot be Empty"); else try con = new SqlConnection(constr); con.open(); str = "Select *from tbuserinfo where code=" + TextBox1.Text.ToString().Trim() + ""; cmd = new SqlCommand(str, con); dr = cmd.executereader(); if (dr.read()) TextBox1.Text = dr.getvalue(0).tostring(); TextBox2.Text = dr.getvalue(1).tostring(); TextBox3.Text = dr.getvalue(2).tostring(); else MessageBox.Show("Record Not Found"); cmd.dispose(); con.close(); catch (Exception ex) MessageBox.Show(ex.Message.ToString()); private void button3_click(object sender, EventArgs e) if (TextBox1.Text.Equals("") && TextBox2.Text.Equals("") && TextBox3.Text.Equals("")) MessageBox.Show("Input datas are cannot be empty"); else try con = new SqlConnection(constr); con.open(); 37

38 str = "Update tbuserinfo Set "; str = str + "name='" + TextBox2.Text.ToString().Trim() + "',"; str = str + " id='" + TextBox3.Text.ToString().Trim() + "' where code=" + TextBox1.Text.ToString().Trim() + ""; cmd = new SqlCommand(str, con); cmd.executenonquery(); MessageBox.Show("Successfully Updated"); cmd.dispose(); con.close(); catch (Exception ex) MessageBox.Show(ex.Message.ToString()); private void button4_click(object sender, EventArgs e) if (TextBox1.Text.Equals("") && TextBox2.Text.Equals("") && TextBox3.Text.Equals("")) MessageBox.Show("Input datas are cannot be empty"); else try con = new SqlConnection(constr); con.open(); str = "Delete from tbuserinfo where code=" + TextBox1.Text.ToString().Trim() + ""; cmd = new SqlCommand(str, con); cmd.executenonquery(); MessageBox.Show("Successfully Deleted"); cmd.dispose(); con.close(); catch (Exception ex) MessageBox.Show(ex.Message.ToString()); 38

39 THE END 39

PLATFORM TECHNOLOGY UNIT-4

PLATFORM TECHNOLOGY UNIT-4 VB.NET: Handling Exceptions Delegates and Events - Accessing Data ADO.NET Object Model-.NET Data Providers Direct Access to Data Accessing Data with Datasets. ADO.NET Object Model ADO.NET object model

More information

UNIT-3. Prepared by R.VINODINI 1

UNIT-3. Prepared by R.VINODINI 1 Prepared by R.VINODINI 1 Prepared by R.VINODINI 2 Prepared by R.VINODINI 3 Prepared by R.VINODINI 4 Prepared by R.VINODINI 5 o o o o Prepared by R.VINODINI 6 Prepared by R.VINODINI 7 Prepared by R.VINODINI

More information

C# winforms gridview

C# winforms gridview C# winforms gridview using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;

More information

ADO.NET Overview. Connected Architecture. SqlConnection, SqlCommand, DataReader class. Disconnected Architecture

ADO.NET Overview. Connected Architecture. SqlConnection, SqlCommand, DataReader class. Disconnected Architecture Topics Data is Everywhere ADO.NET Overview Connected Architecture EEE-474 DATABASE PROGRAMMİNG FOR İNTERNET INTRODUCTION TO ADO.NET Mustafa Öztoprak-2013514055 ASSOC.PROF.DR. TURGAY İBRİKÇİ ÇUKUROVA UNİVERSTY

More information

ADO.NET.NET Data Access and Manipulation Mechanism. Nikita Gandotra Assistant Professor, Department of Computer Science & IT

ADO.NET.NET Data Access and Manipulation Mechanism. Nikita Gandotra Assistant Professor, Department of Computer Science & IT ADO.NET.NET Data Access and Manipulation Mechanism Nikita Gandotra Assistant Professor, Department of Computer Science & IT Overview What is ADO.NET? ADO VS ADO.NET ADO.NET Architecture ADO.NET Core Objects

More information

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below. APPENDIX 1 TABLE DETAILS Mainly three tables namely Teacher, Student and Class for small database of a school are used. The snapshots of all three tables are shown below. Details of Class table are shown

More information

Philadelphia University Faculty of Information Technology. Visual Programming. Using C# -Work Sheets-

Philadelphia University Faculty of Information Technology. Visual Programming. Using C# -Work Sheets- Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji 2018 Work Sheet 1 Hello World! 1. Create a New Project, Name

More information

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

if (say==0) { k.commandtext = Insert into kullanici(k_adi,sifre) values(' + textbox3.text + ',' + textbox4.text + '); k. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient;

More information

1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6.

1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6. C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed

More information

B Nagaraju

B Nagaraju Agenda What to expect in this session Complete ADO.NET Support available in.net Clear Conceptual View Supported by Demos Understand 3 generations of DataAccess.NET Around 9 minutes of videos Free Stuff

More information

ADO.NET for Beginners

ADO.NET for Beginners Accessing Database ADO.NET for Beginners Accessing database using ADO.NET in C# or VB.NET This tutorial will teach you Database concepts and ADO.NET in a very simple and easy-to-understand manner with

More information

Data Access Standards. ODBC, OLE DB, and ADO Introduction. History of ODBC. History of ODBC 4/24/2016

Data Access Standards. ODBC, OLE DB, and ADO Introduction. History of ODBC. History of ODBC 4/24/2016 Data Access Standards ODBC, OLE DB, and ADO Introduction I Gede Made Karma The reasons for ODBC, OLE DB, and ADO are to provide a standardized method and API for accessing and manipulating Data from different

More information

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed

More information

Chapter 6 Dialogs. Creating a Dialog Style Form

Chapter 6 Dialogs. Creating a Dialog Style Form Chapter 6 Dialogs We all know the importance of dialogs in Windows applications. Dialogs using the.net FCL are very easy to implement if you already know how to use basic controls on forms. A dialog is

More information

For this example, we will set up a small program to display a picture menu for a fast food take-away shop.

For this example, we will set up a small program to display a picture menu for a fast food take-away shop. 146 Programming with C#.NET 9 Fast Food This program introduces the technique for uploading picture images to a C# program and storing them in a database table, in a similar way to text or numeric data.

More information

CST242 Windows Forms with C# Page 1

CST242 Windows Forms with C# Page 1 CST242 Windows Forms with C# Page 1 1 2 4 5 6 7 9 10 Windows Forms with C# CST242 Visual C# Windows Forms Applications A user interface that is designed for running Windows-based Desktop applications A

More information

Accessing Databases 7/6/2017 EC512 1

Accessing Databases 7/6/2017 EC512 1 Accessing Databases 7/6/2017 EC512 1 Types Available Visual Studio 2017 does not ship with SQL Server Express. You can download and install the latest version. You can also use an Access database by installing

More information

Philadelphia University Faculty of Information Technology. Visual Programming

Philadelphia University Faculty of Information Technology. Visual Programming Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji Work Sheet 1 Form, Buttons and labels Properties Changing properties

More information

Create a Windows Application that Reads- Writes PI Data via PI OLEDB. Page 1

Create a Windows Application that Reads- Writes PI Data via PI OLEDB. Page 1 Create a Windows Application that Reads- Writes PI Data via PI OLEDB Page 1 1.1 Create a Windows Application that Reads-Writes PI Data via PI OLEDB 1.1.1 Description The goal of this lab is to learn how

More information

UNIT III APPLICATION DEVELOPMENT ON.NET

UNIT III APPLICATION DEVELOPMENT ON.NET UNIT III APPLICATION DEVELOPMENT ON.NET Syllabus: Building Windows Applications, Accessing Data with ADO.NET. Creating Skeleton of the Application Select New->Project->Visual C# Projects->Windows Application

More information

An Introduction to ADO.Net

An Introduction to ADO.Net An Introduction to ADO.Net Mr. Amit Patel Dept. of I.T. .NET Data Providers Client SQL.NET Data Provider OLE DB.NET Data Provider ODBC.NET Data Provider OLE DB Provider ODBC Driver SQL SERVER Other DB

More information

BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED PROGRAMMING, X428.6)

BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED PROGRAMMING, X428.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 7 Professional Program: Data Administration and Management BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED

More information

Answer on Question# Programming, C#

Answer on Question# Programming, C# Answer on Question#38723 - Programming, C# 1. The development team of SoftSols Inc. has revamped the software according to the requirements of FlyHigh Airlines and is in the process of testing the software.

More information

Industrial Programming

Industrial Programming Industrial Programming Lecture 6: C# Data Manipulation Industrial Programming 1 The Stream Programming Model File streams can be used to access stored data. A stream is an object that represents a generic

More information

Microsoft Visual C# 2005: Developing Applications Table of Contents

Microsoft Visual C# 2005: Developing Applications Table of Contents Table of Contents INTRODUCTION...INTRO-1 Prerequisites...INTRO-2 Installing the Practice Files...INTRO-3 Software Requirements...INTRO-3 Sample Database...INTRO-3 Security...INTRO-4 Installation...INTRO-4

More information

Building Datacentric Applications

Building Datacentric Applications Chapter 4 Building Datacentric Applications In this chapter: Application: Table Adapters and the BindingSource Class Application: Smart Tags for Data. Application: Parameterized Queries Application: Object

More information

Controls. By the end of this chapter, student will be able to:

Controls. By the end of this chapter, student will be able to: Controls By the end of this chapter, student will be able to: Recognize the (Properties Window) Adjust the properties assigned to Controls Choose the appropriate Property Choose the proper value for the

More information

A201 Object Oriented Programming with Visual Basic.Net

A201 Object Oriented Programming with Visual Basic.Net A201 Object Oriented Programming with Visual Basic.Net By: Dr. Hossein Computer Science and Informatics IU South Bend 1 What do we need to learn in order to write computer programs? Fundamental programming

More information

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems Excel and C# Overview Introduction to DatabaseSupport Systems Building a Web-Enabled Decision Support System Integrating DSS in Business Curriculum 2 Decision Support Systems (DSS) A decision support system

More information

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) ) create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) ) insert into bolumler values(1,'elektrik') insert into bolumler values(2,'makina') insert into bolumler

More information

Unit-1. Components of.net Framework. 1. Introduction to.net Framework

Unit-1. Components of.net Framework. 1. Introduction to.net Framework 1 Unit-1 1. Introduction to.net Framework The.NET framework is a collection of all the tools and utilities required to execute the.net managed applications on a particular platform. The MS.NET framework

More information

> ADO.NET: ActiveX Data Objects for.net, set of components used to interact with any DB/ XML docs

> ADO.NET: ActiveX Data Objects for.net, set of components used to interact with any DB/ XML docs > ADO.NET: ActiveX Data Objects for.net, set of components used to interact with any DB/ XML docs It supports 2 models for interacting with the DB: 1. Disconnected Model 2. Connection Oriented Model Note:

More information

Lecture 10: Database. Lisa (Ling) Liu

Lecture 10: Database. Lisa (Ling) Liu Chair of Software Engineering C# Programming in Depth Prof. Dr. Bertrand Meyer March 2007 May 2007 Lecture 10: Database Lisa (Ling) Liu Database and Data Representation Database Management System (DBMS):

More information

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at: This document describes how to create a simple Windows Forms Application using some Open Core Interface functions in C# with Microsoft Visual Studio Express 2013. 1 Preconditions The Open Core Interface

More information

It is the primary data access model for.net applications Next version of ADO Can be divided into two parts. Resides in System.

It is the primary data access model for.net applications Next version of ADO Can be divided into two parts. Resides in System. It is the primary data access model for.net applications Next version of ADO Can be divided into two parts Providers DataSets Resides in System.Data namespace It enables connection to the data source Each

More information

CALCULATOR APPLICATION

CALCULATOR APPLICATION CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;

More information

Data Source. Application. Memory

Data Source. Application. Memory Lecture #14 Introduction Connecting to Database The term OLE DB refers to a set of Component Object Model (COM) interfaces that provide applications with uniform access to data stored in diverse information

More information

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project. C# Tutorial - Create a Batman Gravity Run Game Start a new project in visual studio and call it gravityrun It should be a windows form application with C# Click OK Change the size of the to 800,300 and

More information

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox] C# Tutorial - Create a Tic Tac Toe game with Working AI This project will be created in Visual Studio 2010 however you can use any version of Visual Studio to follow along this tutorial. To start open

More information

CMPT 354 Database Systems I

CMPT 354 Database Systems I CMPT 354 Database Systems I Chapter 8 Database Application Programming Introduction Executing SQL queries: Interactive SQL interface uncommon. Application written in a host language with SQL abstraction

More information

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Before you start - download the game assets from above or on MOOICT.COM to

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

ADO.NET from 3,048 meters

ADO.NET from 3,048 meters C H A P T E R 2 ADO.NET from 3,048 meters 2.1 The goals of ADO.NET 12 2.2 Zooming in on ADO.NET 14 2.3 Summary 19 It is a rare opportunity to get to build something from scratch. When Microsoft chose the

More information

IBSDK Quick Start Tutorial for C# 2010

IBSDK Quick Start Tutorial for C# 2010 IB-SDK-00003 Ver. 3.0.0 2012-04-04 IBSDK Quick Start Tutorial for C# 2010 Copyright @2012, lntegrated Biometrics LLC. All Rights Reserved 1 QuickStart Project C# 2010 Example Follow these steps to setup

More information

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية وتمتلك الشفرة البرمجية التالية : زر االقسام fr_dept fd = new

More information

Web Services in.net (2)

Web Services in.net (2) Web Services in.net (2) These slides are meant to be for teaching purposes only and only for the students that are registered in CSE4413 and should not be published as a book or in any form of commercial

More information

In-Class Worksheet #4

In-Class Worksheet #4 CSE 459.24 Programming in C# Richard Kidwell In-Class Worksheet #4 Creating a Windows Forms application with Data Binding You should have Visual Studio 2008 open. 1. Create a new Project either from the

More information

You can call the project anything you like I will be calling this one project slide show.

You can call the project anything you like I will be calling this one project slide show. C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise

More information

Click on the empty form and apply the following options to the properties Windows.

Click on the empty form and apply the following options to the properties Windows. Start New Project In Visual Studio Choose C# Windows Form Application Name it SpaceInvaders and Click OK. Click on the empty form and apply the following options to the properties Windows. This is the

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

CHAPTER 3. Writing Windows C# Programs. Objects in C#

CHAPTER 3. Writing Windows C# Programs. Objects in C# 90 01 pp. 001-09 r5ah.ps 8/1/0 :5 PM Page 9 CHAPTER 3 Writing Windows C# Programs 5 9 Objects in C# The C# language has its roots in C++, Visual Basic, and Java. Both C# and VB.Net use the same libraries

More information

EPSON RC+ 7.0 Option. GUI Builder 7.0 EM145A2719F. Rev. 2

EPSON RC+ 7.0 Option. GUI Builder 7.0 EM145A2719F. Rev. 2 EPSON RC+ 7.0 Option GUI Builder 7.0 Rev. 2 EM145A2719F EPSON RC+ 7.0 Option GUI Builder 7.0 Rev.2 EPSON RC+ 7.0 Option GUI Builder 7.0 Rev.2 Copyright 2012-2014 SEIKO EPSON CORPORATION. All rights reserved.

More information

.NET and DB2 united with IBM DB2.NET Data Provider Objectives :.NET ADO.NET DB2 and ADO.NET DB2 - ADO.NET applications

.NET and DB2 united with IBM DB2.NET Data Provider Objectives :.NET ADO.NET DB2 and ADO.NET DB2 - ADO.NET applications .NET and DB2 united with IBM DB2.NET Data Provider Objectives :.NET ADO.NET DB2 and ADO.NET DB2 - ADO.NET applications ABIS Training & Consulting 1 DEMO Win Forms client application queries DB2 according

More information

Visual C# Program: Simple Game 3

Visual C# Program: Simple Game 3 C h a p t e r 6C Visual C# Program: Simple Game 3 In this chapter, you will learn how to use the following Visual C# Application functions to World Class standards: Opening Visual C# Editor Beginning a

More information

Programming in C# Project 1:

Programming in C# Project 1: Programming in C# Project 1: Set the text in the Form s title bar. Change the Form s background color. Place a Label control on the Form. Display text in a Label control. Place a PictureBox control on

More information

Mobile MOUSe ADO.NET FOR DEVELOPERS PART 1 ONLINE COURSE OUTLINE

Mobile MOUSe ADO.NET FOR DEVELOPERS PART 1 ONLINE COURSE OUTLINE Mobile MOUSe ADO.NET FOR DEVELOPERS PART 1 ONLINE COURSE OUTLINE COURSE TITLE ADO.NET FOR DEVELOPERS PART 1 COURSE DURATION 14 Hour(s) of Interactive Training COURSE OVERVIEW ADO.NET is Microsoft's latest

More information

Radius= 10 cm, Color= Red, Weight= 200g, X= 3m, Y= 5m, Z= 2m. Radius= 10 cm, Color= Blue, Weight= 200g, X= 3m, Y= 5m, Z= 0m

Radius= 10 cm, Color= Red, Weight= 200g, X= 3m, Y= 5m, Z= 2m. Radius= 10 cm, Color= Blue, Weight= 200g, X= 3m, Y= 5m, Z= 0m C# property method Radius= 10 cm, Color= Red, Weight= 200g, X= 3m, Y= 5m, Z= 0m Radius= 10 cm, Color= Red, Weight= 200g, X= 3m, Y= 5m, Z= 2m Radius= 10 cm, Color= Blue, Weight= 200g, X= 3m, Y= 5m, Z= 0m

More information

Full file at https://fratstock.eu Programming in Visual Basic 2010

Full file at https://fratstock.eu Programming in Visual Basic 2010 OBJECTIVES: Chapter 2 User Interface Design Upon completion of this chapter, your students will be able to 1. Use text boxes, masked text boxes, rich text boxes, group boxes, check boxes, radio buttons,

More information

GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4

GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4 GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4 Subject Name VISUAL BASIC Sr.No Course content 1. 1. Introduction to Visual Basic 1.1. Programming Languages 1.1.1. Procedural,

More information

Inheriting Windows Forms with Visual C#.NET

Inheriting Windows Forms with Visual C#.NET Inheriting Windows Forms with Visual C#.NET Overview In order to understand the power of OOP, consider, for example, form inheritance, a new feature of.net that lets you create a base form that becomes

More information

Object oriented lab /second year / review/lecturer: yasmin maki

Object oriented lab /second year / review/lecturer: yasmin maki 1) Examples of method (function): Note: the declaration of any method is : method name ( parameters list ).. Method body.. Access modifier : public,protected, private. Return

More information

Create your own Meme Maker in C#

Create your own Meme Maker in C# Create your own Meme Maker in C# This tutorial will show how to create a meme maker in visual studio 2010 using C#. Now we are using Visual Studio 2010 version you can use any and still get the same result.

More information

#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll>

#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll> Lecture #9 Introduction Anatomy of Windows Forms application Hand-Coding Windows Form Applications Although Microsoft Visual Studio makes it much easier for developers to create Windows Forms applications,

More information

Tutorial 3 - Welcome Application

Tutorial 3 - Welcome Application 1 Tutorial 3 - Welcome Application Introduction to Visual Programming Outline 3.1 Test-Driving the Welcome Application 3.2 Constructing the Welcome Application 3.3 Objects used in the Welcome Application

More information

Yes, this is still a listbox!

Yes, this is still a listbox! Yes, this is still a listbox! Step 1: create a new project I use the beta 2 of Visual Studio 2008 ( codename Orcas ) and Expression Blend 2.0 September preview for this tutorial. You can download the beta2

More information

Using Visual Basic Studio 2008

Using Visual Basic Studio 2008 Using Visual Basic Studio 2008 Recall that object-oriented programming language is a programming language that allows the programmer to use objects to accomplish a program s goal. An object is anything

More information

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 3 Windows Database Applications McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Objectives - 1 Retrieve and display data from a SQL Server database on Windows forms Use the

More information

عنوان مقاله : خواندن و نوشتن محتوای فایل های Excel بدون استفاده ازAutomation Excel تهیه وتنظیم کننده : مرجع تخصصی برنامه نویسان

عنوان مقاله : خواندن و نوشتن محتوای فایل های Excel بدون استفاده ازAutomation Excel تهیه وتنظیم کننده : مرجع تخصصی برنامه نویسان در این مقاله با دو روش از روشهای خواندن اطالعات از فایل های اکسل و نوشتن آنها در DataGridView بدون استفاده از ( Automation Excelبا استفاده از NPOI و( ADO.Net آشنا میشوید. راه اول : با استفاده از (xls)

More information

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display Experiment 5 : Creating a Windows application to interface with 7-Segment LED display Objectives : 1) To understand the how Windows Forms in the Windows-based applications. 2) To create a Window Application

More information

About the Authors Introduction p. 1 Exploring Application Architectures p. 9 Introduction p. 9 Choosing the "Right" Architecture p.

About the Authors Introduction p. 1 Exploring Application Architectures p. 9 Introduction p. 9 Choosing the Right Architecture p. Foreword p. xxi Acknowledgments p. xxiii About the Authors p. xxv Introduction p. 1 Exploring Application Architectures p. 9 Introduction p. 9 Choosing the "Right" Architecture p. 10 Understanding Your

More information

AUTHENTICATED WEB MANAGEMENT SYSTEM

AUTHENTICATED WEB MANAGEMENT SYSTEM AUTHENTICATED WEB MANAGEMENT SYSTEM Masters Project Report (CPEG 597) December 2005 Submitted to Prof. Ausif Mahmood ID. 655795 By Kavya P Basa 1 Abstract In an era where web development is taking priority

More information

Tutorial 5 Completing the Inventory Application Introducing Programming

Tutorial 5 Completing the Inventory Application Introducing Programming 1 Tutorial 5 Completing the Inventory Application Introducing Programming Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a

More information

VB.NET. Q.1 Explain.Net Framework Architecture. OR Components of.net Framework

VB.NET. Q.1 Explain.Net Framework Architecture. OR Components of.net Framework Q.1 Explain.Net Framework Architecture. OR Components of.net Framework Net Framework is a platform that provides tools and technologies to develop Windows, Web and Enterprise applications. It mainly contains

More information

Chapter 12. Tool Strips, Status Strips, and Splitters

Chapter 12. Tool Strips, Status Strips, and Splitters Chapter 12 Tool Strips, Status Strips, and Splitters Tool Strips Usually called tool bars. The new ToolStrip class replaces the older ToolBar class of.net 1.1. Create easily customized, commonly employed

More information

The original of this document was developed by the Microsoft special interest group. We made some addons.

The original of this document was developed by the Microsoft special interest group. We made some addons. Naming Conventions for.net / C# Projects Martin Zahn, Akadia AG, 20.03.2003 The original of this document was developed by the Microsoft special interest group. We made some addons. This document explains

More information

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

} } public void getir() { DataTable dt = vt.dtgetir(select* from stok order by stokadi); Form1 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

More information

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer C# Tutorial Create a Motivational Quotes Viewer Application in Visual Studio In this tutorial we will create a fun little application for Microsoft Windows using Visual Studio. You can use any version

More information

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components;

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; Exercise 9.3 In Form1.h #pragma once #include "Form2.h" Add to the beginning of Form1.h #include #include For srand() s input parameter namespace Tst_Form using namespace System; using

More information

Datalogging and Monitoring

Datalogging and Monitoring Datalogging and Monitoring with Step by Step Examples Hans-Petter Halvorsen http://www.halvorsen.blog Content Different Apps for Data Logging and Data Monitoring will be presented Here you find lots of

More information

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0. Sub To Srt Converter This is the source code of this program. It is made in C# with.net 2.0. form1.css /* * Name: Sub to srt converter * Programmer: Paunoiu Alexandru Dumitru * Date: 5.11.2007 * Description:

More information

Volume CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET. Getting Started Guide

Volume CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET. Getting Started Guide Volume 1 CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET Getting Started Guide TABLE OF CONTENTS Table of Contents Table of Contents... 1 Chapter 1 - Installation... 2 1.1 Installation Steps... 2 1.1 Creating

More information

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Event-driven, code-behind programming Visual Studio.NET WinForms Controls Part 1 Event-driven, code-behind programming

More information

Form Properties Window

Form Properties Window C# Tutorial Create a Save The Eggs Item Drop Game in Visual Studio Start Visual Studio, Start a new project. Under the C# language, choose Windows Form Application. Name the project savetheeggs and click

More information

Database Communication in Visual Studio/C# using Web Services

Database Communication in Visual Studio/C# using Web Services https://www.halvorsen.blog Database Communication in Visual Studio/C# using Web Services Hans-Petter Halvorsen Background With Web Services you can easily get your data through Internet We will use Web

More information

2017/ st Sec Final revision Final revision

2017/ st Sec Final revision Final revision Q1)Put ( ) or (x): 1. We open channel of communication between the programme that is created in Visual basic Dot Net language and Excel file by using ADO.NET tools. ( ) 2. Variable of type ( OleDbConnection)

More information

Event-based Programming

Event-based Programming Window-based programming Roger Crawfis Most modern desktop systems are window-based. What location do I use to set this pixel? Non-window based environment Window based environment Window-based GUI s are

More information

CSIS 1624 CLASS TEST 6

CSIS 1624 CLASS TEST 6 CSIS 1624 CLASS TEST 6 Instructions: Use visual studio 2012/2013 Make sure your work is saved correctly Submit your work as instructed by the demmies. This is an open-book test. You may consult the printed

More information

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them. We are working on Visual Studio 2010 but this project can be remade in any other version of visual studio. Start a new project in Visual Studio, make this a C# Windows Form Application and name it zombieshooter.

More information

Reading From Databases

Reading From Databases 57076_Ch 8 SAN.qxd 01/12/2003 6:43 PM Page 249 8 Reading From Databases So far in this book you've learnt a lot about programming, and seen those techniques in use in a variety of Web pages. Now it's time

More information

Visual Studio Windows Form Application #1 Basic Form Properties

Visual Studio Windows Form Application #1 Basic Form Properties Visual Studio Windows Form Application #1 Basic Form Properties Dr. Thomas E. Hicks Computer Science Department Trinity University Purpose 1] The purpose of this tutorial is to show how to create, and

More information

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

Eyes of the Dragon - XNA Part 37 Map Editor Revisited Eyes of the Dragon - XNA Part 37 Map Editor Revisited I'm writing these tutorials for the XNA 4.0 framework. Even though Microsoft has ended support for XNA it still runs on all supported operating systems

More information

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende: APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende: Interfaz gráfica de wiimocap. Obtención de las variables de los tres acelerómetros. Algoritmos de reconocimiento de posiciones. Inclinación

More information

END-TERM EXAMINATION

END-TERM EXAMINATION (Please Write your Exam Roll No. immediately) END-TERM EXAMINATION DECEMBER 2006 Exam. Roll No... Exam Series code: 100274DEC06200274 Paper Code : MCA-207 Subject: Front End Design Tools Time: 3 Hours

More information

Lab 4 (Introduction to C# and windows Form Applications)

Lab 4 (Introduction to C# and windows Form Applications) Lab 4 (Introduction to C# and windows Form Applications) In this the following goals will be achieved: 1. C# programming language is introduced 2. Creating C# console application using visual studio 2008

More information

Unit 3. Lesson Designing User Interface-2. TreeView Control. TreeView Contol

Unit 3. Lesson Designing User Interface-2. TreeView Control. TreeView Contol Designing User Interface-2 Unit 3 Designing User Interface-2 Lesson 3.1-3 TreeView Control A TreeView control is designed to present a list in a hierarchical structure. It is similar to a directory listing.

More information

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content Step 1: Start a GUI Project Start->New Project->Visual C# ->Windows Forms Application Name: Wack-A-Gopher Step 2: Add Content Download the Content folder (content.zip) from Canvas and unzip in a location

More information

ADO.NET 2.0. database programming with

ADO.NET 2.0. database programming with TRAINING & REFERENCE murach s ADO.NET 2.0 database programming with (Chapter 3) VB 2005 Thanks for downloading this chapter from Murach s ADO.NET 2.0 Database Programming with VB 2005. We hope it will

More information

Ingegneria del Software T. Interfaccia utente

Ingegneria del Software T. Interfaccia utente Interfaccia utente Creating Windows Applications Typical windows-application design & development 1+ classes derived from System.Windows.Forms.Form Design UI with VisualStudio.NET Possible to do anything

More information

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank)

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank) Unit-1 (overview of Microsoft.net framework) 1. What is CLR? What is its use? (2 times) 2 2. What is garbage collection? 2 3. Explain MSIL 2 4. Explain CTS in detail 2 5. List the extension of files available

More information

DOT NET SYLLABUS FOR 6 MONTHS

DOT NET SYLLABUS FOR 6 MONTHS DOT NET SYLLABUS FOR 6 MONTHS INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate

More information