SQL Server. System.Data.SqlClient

Similar documents
User Manual SDVD " Portable DVD Player

Accessing Databases 7/6/2017 EC512 1

STEP 1: CREATING THE DATABASE

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.

Advanced Programming C# Lecture 5. dr inż. Małgorzata Janik

ADO.NET. Two Providers ADO.NET. Namespace. Providers. Behind every great application is a database manager

Datalogging and Monitoring

Industrial Programming

Blackbird Books and Supplies

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

ADO.NET in Visual Basic

Melon, Inc. Melon Components Starter Kit

VB. Microsoft. MS.NET Framework 3.5 ADO.NET Application Development

ITcertKing. The latest IT certification exam materials. IT Certification Guaranteed, The Easy Way!

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

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

Final Documentation. Created By: Ahnaf Salam Adam Castillo Sergio Montejano Elliot Galanter

Database Lab. Hans-Petter Halvorsen

PLATFORM TECHNOLOGY UNIT-4

C# winforms gridview

JapanCert 専門 IT 認証試験問題集提供者

.NET Connector. (MS Windows)

Pentatonic Labs Final Documentation

3 Customer records. Chapter 3: Customer records 57

Final Documentation Solutions Inc TEAM SOLUTION Micheal Scott Trevor Moore Aurian James Wes Bailoni

Encrypt and Decrypt Username or Password stored in database in ASP.Net using C# and VB.Net

Examcollection.

In the previous chapter we created a web site with images programmed into HTML page code using commands such as: <img src="images/train.

This PDF was generated in real-time using DynamicPDF; Generator for.net.

An Introduction to ADO.Net

web.config Register.aspx را بصورت زیر بنویسید.

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

UNIT-3. Prepared by R.VINODINI 1

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

ADO.NET 2.0. database programming with

3-tier Architecture Step by step Exercises Hans-Petter Halvorsen

Supporting Non-Standard Development Configurations

QDABRA DBXL S XML RENDERING SERVICE CONFIGURATION

Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

DESIGN AND IMPLEMENTATION OF A MOBILE MANAGEMENT SYSTEM FOR CAMPUS SERVER

Upgrade: Transition your MCPD.NET Framework 3.5 Web Developer Skills to MCPD.NET Framework 4 Web Developer

Real4Test. Real IT Certification Exam Study materials/braindumps

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

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

ADO.NET Guide. RDM Server 8.2

Insert Data into Table using C# Code

Introduction. Three button technique. "Dynamic Data Grouping" using MS Reporting Services Asif Sayed

ngaio.)' Thif. as you ore doubtless aware U the

Answer on Question# Programming, C#

Oracle Rdb Developer Tools for Visual Studio Developer's Guide Release June 2015

Web Forms User Security and Administration

Create a Login System in Visual Basic. Creating a login system. Start a new visual basic Windows Forms application project. Call it Login System

IProtect Basic Installation Manual. (Distributed)

COMPUTER SCIENCE 260CT SOFTWARE ENGINEERING

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

Accessing Data in ASP.NET

This PDF was generated in real-time using DynamicPDF; Generator for.net.

Client-Side ADO.NET. Chapter 6

Configuring RentalPoint Web Services

EDB Postgres Advanced Server.NET Connector Guide

1 string start = DateTime.Now.ToShortDateString(); 2 string end = DateTime.Now.AddDays(5).ToShortDateString(); 3 OleDbConnection conn2 =

EDB Postgres Advanced Server.NET Connector Guide

Oracle Rdb Technical Forums

Class Test 5. Create a simple paint program that conforms to the following requirements.

Oracle Rdb Developer Tools for Visual Studio Developer s Guide, Release Copyright 2011 Oracle Corporation Corporation. All rights reserved.

EDB Postgres Advanced Server.NET Connector Guide

Lecture 10: Database. Lisa (Ling) Liu

Yet Another Forum Integration

Introduction. What is Recursive Data? Reporting on Hierarchical Recursive data using MS Reporting Services Asif Sayed

ComponentOne. DataObjects for.net

EDB Postgres Advanced Server.NET Connector Guide

Exception/Error Handling in ASP.Net

Microsoft VB. Accessing Data with Microsoft.NET Framework. Download Full Version :

LINQ In C# LINQ LINQ In C# LINQ In C# 118 LINQ

UNIT III APPLICATION DEVELOPMENT ON.NET

Getting Started with IVI-COM Drivers for the Lambda Genesys Power Supply

The best way to begin understanding this wonderful new technology is to take a look at some history and background on how and why LINQ came to be.

Live TV Station Broadcasting by Utilizing Windows. Server2008 (Windows Media Service) and Video. Advertisement Management by Utilizing Server-side

Software Development Kit. User Guide

Disconnected Data Access

Part 1: Create User Defined Type PointType

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.

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

How to work with data sources and datasets

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

Employee Attendance System module using ASP.NET (C#)

Expert System and Heuristics Algorithm for Cloud Resource Scheduling

MVC - Repository-And-Unit-Of-Work

Data Source. Application. Memory

The ADO Connection Object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.

This PDF was generated in real-time using DynamicPDF; Generator for.net.

Installation Guide for the Survey Project Web Application

Mizu VOIP Server Database Interface

ADO.NET for Beginners

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable();

8 Library loan system

32-bit Oracle Data Access Components (ODAC) with Oracle Developer Tools for Visual Studio

CSharp. Microsoft. TS- MS.NET Framework 3.5 ADO.NET Application Development

WF-distiller Installation Guide

VB. Microsoft. PRO-Design and Develop Web-Based Apps by Using MS.NET Framework

Transcription:

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W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1 Windows AddressList 1 System.Data.SqlClient using System.Data.SqlClient; 2 string connstring =@"Data Source=.\sqlexpress;Initial Catalog=AddressList; Integrated Security=True"; SqlConnection connection = new SqlConnection(connString); connection.open(); MessageBox.Show(" connection.close(); MessageBox.Show(" SqlConnection 2.1.2 SqlConnection SqlConnection SQL Server SqlConnection 2-1 2-1 SqlConnection ConnectionString Open Close 3 1 2-1

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf (YeJ@5/Khe J@HeN@Lf O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh 7@f@1f O&0YfI'@6Kf @@e@@@@@@@@e@@f @@f@@f 3@f@@f O2@6Kg V+Ye N@LeJ@@f @(MI'@f @)KO&@5f @@e@@e@@e@@f I4@@@@Hf @@f @(Mhf@5f J@5f (Y (Yf @@0Mh O&0Yg W&(Yf W&(Yg 2 9 Windows SQL Server SQL Server Windows Data Source=.\sqlexpress;Initial Catalog=AddressList;Integrated Security=True Data Source SQL Server. Microsoft SQL Server Express Edition.\sqlexpress Initial Catalog AddressList Integrated Security True Windows SQL Server Data Source=.\sqlexpress;Initial Catalog=AddressList;uid=sa;pwd=sa uid pwd SQL Server A 2 SqlConnection SqlConnection SqlConnection connection = new SqlConnection(connString); 3 SqlConnection Open() connection.open(); SqlConnection Close() connection.close(); 2.1.3.NET try catch finally finally string connstring =@"Data Source=.\sqlexpress;Initial Catalog=AddressList;uid=sa;pwd=sa"; SqlConnection connection = new SqlConnection(connString); try connection.open(); MessageBox.Show(" catch (Exception ex) MessageBox.Show(ex.ToString()); finally connection.close();

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye W.MeI/Xf 7HeN1f @@e@@e@@e@@f J@g@Lf 7@g@1f @(Mhf@5f W2@@6Xg (Y (Yf @@@@@@@@f @@h @@g@@f 3@g@5f N@g@Hf 3LeJ5f V/KeO.Yf V4@@0Yg 10 MessageBox.Show(" 2.1.4 using C# using SqlConnection using string connstring =@"Data Source=.\sqlexpress;Initial Catalog=AddressList;uid=sa;pwd=sa"; using (SqlConnection connection = new SqlConnection(connString)) connection.open(); MessageBox.Show(" using 2.2 2.2.1 2-2 2-2 2-2 2-2 TextBox Button txtusername txtuserpassword PasswordChar * btnlogin Text btncancel Text 2.2.2 private void btnlogin_click(object sender, EventArgs e) if (txtusername.text.trim() == "" txtuserpassword.text.trim() == "") MessageBox.Show(" txtusername.focus(); return; string connstring = @"Data Source=.\sqlexpress;Initial Catalog=AddressList;Integrated Security=True"; string sqlstr = string.format("select count(*) from [User] where UserName='0' and Password='1'", txtusername.text.trim(), txtuserpassword.text.trim());

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye @@@@@h O2@h @@e@@e@@e@@f @(Mhf@5f (Y (Yf @@@@@@@@f @@h @@@@@@@@f @@h 2 11 using (SqlConnection conn = new SqlConnection(connString)) SqlCommand cmd = new SqlCommand(sqlStr, conn); conn.open(); int n = Convert.ToInt32(cmd.ExecuteScalar()); if (n==1) MessageBox.Show(" else MessageBox.Show(",!", " txtusername.text = ""; txtuserpassword.text = ""; txtusername.focus(); private void btncancel_click(object sender, EventArgs e) this.close(); SQL string.format string sqlstr = string.format("select count(*) from [User] where UserName='0' and Password='1'", txtusername.text.trim(), txtuserpassword.text.trim()); admin admin SQL select count(*) from [User] where UserName='admin' and Password='admin' UserName Password varchar User User SQL Server SQL B,! SqlCommand 2.2.3 SqlCommand SqlCommand SQL SqlCommand 1 SqlConnection 2.1.2 SqlConnection 2 SQL SQL 3 SqlCommand SqlCommand SqlCommand SQL SqlConnection

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye W&@@@@)Xf 7(MI'@1f @@e@@e@@e@@f @HeN@@f @f@@f W2@@6Xg @(Mhf@5f @@f (Y (Yf @@@@@@@@f @5f @@h W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f 12 SqlCommand cmd = new SqlCommand(sqlStr, conn); 4 SqlCommand SQL SqlCommand SqlCommand 2-3 2-3 SqlCommand ExecuteScalar ExecuteNonQuery ExecuteReader object SQL SqlDataReader SqlCommand ExecuteScalar ExecuteScalar object int n = Convert.ToInt32(cmd.ExecuteScalar()); n 1 SqlCommand ExecuteNonQuery SqlCommand ExecuteReader SqlDataReader SqlDataReader 2.2.4 SqlDataReader SqlDataReader SQL Server SqlDataReader SqlDataReader 2-4 2-4 SqlDataReader HasRows true false FieldCount Read true false Close SqlDataReader SqlDataReader 1 SqlCommand SqlCommand cmd = new SqlCommand(sqlStr, conn); 2 SqlCommand ExecuteReader SqlDataReader conn.open(); SqlDataReader dr = cmd.executereader();

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye W&@@@)Xg.MI'1g W2@6Xg @@e@@e@@e@@f @(Mhf@5f (Y (Yf @@@@@@@@f @@@@)Xf O&Ug N@g @g J5g @@h '6KO.Yg I'@1f V4@@0Yg V'@f N@f J5f W.Yf 2 13 3 SqlDataReader Read true false dr.read(); 4 dr[0].tostring() 0 dr["groupname"].tostring() object 5 Close SqlDataReader SqlDataReader Close SqlDataReader dr.close(); SqlCommand SqlDataReader private void btnlogin_click(object sender, EventArgs e) if (txtusername.text.trim() == "" txtuserpassword.text.trim() == "") MessageBox.Show(" txtusername.focus(); return; string connstring = @"Data Source=.\sqlexpress;Initial Catalog=AddressList;Integrated Security=True"; string sqlstr = string.format("select * from [User] where UserName='0' and Password='1'", txtusername.text.trim(), txtuserpassword.text.trim()); using (SqlConnection conn = new SqlConnection(connString)) SqlCommand cmd = new SqlCommand(sqlStr, conn); conn.open(); SqlDataReader sdr = cmd.executereader(); if (sdr.read()) MessageBox.Show(" else MessageBox.Show(",!", " txtusername.text = ""; txtuserpassword.text = ""; txtusername.focus(); sdr.close(); SqlCommand ExecuteReader SqlDataReader SqlDataReader Read Read true Read false

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f W&g V+Ye @@e@@e@@e@@f @(Mhf@5f (Y (Yf @@@@@@@@f W.Yf@@g W.Ye@@g W.Ye@@g W.Y@@g W.Y@@g W&@g W&@@g @@h 7Yf@@g @@@@@@@@@@@f @@g 14 2.2.5 SQL 2.2.4 using (SqlConnection conn = new SqlConnection(connString)) F9 Visual Studio 2008 2-3 2-3 SQL sqlstr 2-3 2-4 SQL SQL SQL Server SQL F9 2-4 2.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6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye @@@@@@@f J(Mh @@e@@e@@e@@f 7Yhe @@6Kh @(Mhf@5f @@@@6Xg (Y (Yf @@@@@@@@f I4@@)Xf I'@1f @@h '6KO.Yg V'@f V4@@0Yg N@f J5f W.Yf 2 15 2-5 Visual Studio 2008 App.config <xml version="1.0" encoding="utf-8" > <configuration> </configuration> App.config XML <xml version="1.0" encoding="utf-8" > <configuration> <connectionstrings> <add name="connectionstring" connectionstring="data Source=.\sqlexpress;Initial Catalog=AddressList;Integrated Security=True" providername="system.data.sqlclient" /> </connectionstrings> </configuration> ConnectionString 2.3.2.NET 1 Visual Studio 2008 System. Configuration 2-6 2-6

W.MeI/Xf 7HeN1f J@g@Lf 7@g@1f W2@@6Xg W&@@@@)Xf 7(MI'@1f @HeN@@f @@g@@f @f@@f W2@@6Xg 3@g@5f @@f N@g@Hf @5f 3LeJ5f V/KeO.Yf V4@@0Yg W&Yf@f J@Hf W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g &@@@@@@@@f W&@@@@)Xf 7(MI'@1f @HeN@@f @f@@f W2@@6Xg @@f @5f J@Hf W.MeI/Xf W&Yf@f W&@@@@@@@f W.Yh W.Ye@f J(Yg W.Yg 75g 7HeN1f J@g@Lf 7@g@1f W2@@6Xg @@@@@h O2@h &@@@@@@@@f @@g@@f 3@g@5f N@g@Hf 3LeJ5f W&@@@@)Xf V/KeO.Yf 7(MI'@1f V4@@0Yg @HeN@@f @f@@f W2@@6Xg @@@@@@@@f @@f @5f W2@6Xg J@Hf W.MI/Xf @@h 75g 7HeN1f J(Yg @f@f W&Yf@f W&@@@@@@@f &@@@@@@@@f W.Yh W.Ye@f W.Yg @LeJ5f 3)KO.Yf V'@@@Hg S@@@Lg @@@@@h O2@h @@ W.R4@)Xf W.YeI')Xf 7HeV'1f @gn@f @g@f 3LfJ5f @@@@@h O2@h V/KeO.Yf V4@@@0Yf @@ @@@@@h O2@h @@@@@@@@f @@h @@@@@@@@f @@h @@f @@@@@h O2@h @@@@@@@@f @@@@@@@5f @@@@@@@@f @@h @@f @f@hf @f@g J5g 7Hg @g @@@@@@@@f @@h J5h J5g 7Hh 7Hg @he @h J5h 7Hh @h @KO&YfO26Xf J(Yhg @@(Mhf @(Yhf O&@)Xe W-Xe @@@@@@@@@@@@@@@)f @@he@@hf @@f@kf@@g @@f@@@e@@g @@f@@he@@g @Kf@Yf @@@@@@@@@@@@@@@@@@)e @@e@@e@@e@@he @@f@@f@@g @@(Mhe @@ej@5f@5g @@Hhf @0M @5e7@Hf(Yg @5hf @@@@@h O2@h (YeJ@5/Khe O20MheI'@,e O20MgV4@@6Xe W&(YV46Kh O&0YfI'@6Kf @@e@@@@@@@@e@@f V+Ye @@e@@e@@e@@f W&(Yh 7@Hhe @(Mhf@5f @@he W2(Mg W&(Yh O2@@f (Y (Yf @@@@@@@@f J@@@@6Kg 7@(MI'@g @@h @@HeN@Lf @@f@1f @@f@@f 3@f@5f N@LeJ@Hf @)KO&@g I4@0Mg 16 2 using System.Configuration; 3 ConfigurationManager ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; ConnectionString DBHelper DBHelper class DBHelper public static string connstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string connstring = DBHelper.connString; SqlConnection SqlCommand SqlDataReader 1. 2.