1 Working with MS SQL Server Beginning ASP.NET 4.5.1 in C# and VB Chapter 12.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

Microsoft SQL Server 2008 From the Program menu choose: Microsoft SQL Server 2008 R2  SQL Server Management Studio. You may see a window indicating the.
Access Lesson 2 Creating a Database
Exploring Microsoft Excel 2002 Chapter 7 Chapter 7 List and Data Management: Converting Data to Information By Robert T. Grauer Maryann Barber Exploring.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
The Use of Microsoft based Technologies for the benefit of the Community Prof. Avi Mendelson – Microsoft & Technion - Taub 643.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
Concepts of Database Management Sixth Edition
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Microsoft Access 2010 Chapter 7 Using SQL.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
Chapter 2 Querying a Database
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
ASP.NET Programming with C# and SQL Server First Edition
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
Database Applications – Microsoft Access Lesson 9 Designing Special Queries.
Chapter 10: Working with Large Data Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
MS Access Database Connection. Database? A database is a program that stores data and records in a structured and queryable format. The tools that are.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Chapter 15: Using LINQ to Access Data in C# Programs.
Microsoft Access 2010 Building and Using Queries.
Analyzing Data For Effective Decision Making Chapter 3.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Key Applications Module Lesson 21 — Access Essentials
Concepts of Database Management Seventh Edition
Chapter 17 Creating a Database.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Analysing Data with Excel Viewing Help To view Help 1.On the Start menu, point to Programs, and then click Microsoft Excel. 2.On the Help menu,
Visual Programing SQL Overview Section 1.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Creating and Populating a MS SQLServer Database Presented By: Dr. Adam P. Anthony.
Planning & Creating a Database By Ms. Naira Microsoft Access.
Excel part 5 Working with Excel Tables, PivotTables, and PivotCharts.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
COMPUTER SKILLS MS-ACCESS. Introduction Access is a piece of software known as a database management system. At its most basic level, it can be used to.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Aga Private computer Institute Prepared by: Srwa Mohammad
Visual Basic 2010 How to Program
Practical Office 2007 Chapter 10
Chapter 4 MS ACCESS DATABASE.
MS Access Database Connection
Microsoft Office Access 2003
Developing a Model-View-Controller Component for Joomla Part 3
Microsoft Office Access 2003
CIS16 Application Programming with Visual Basic
These slides are for reference only. They are not "lecture notes"
Grauer and Barber Series Microsoft Access Chapter One
Assignment resource Working with Excel Tables, PivotTables, and Pivot Charts Fairhurst pp The commands on these slides work with the Week 2 Excel.
Presentation transcript:

1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12

2 Objectives You will be able to Use Visual Studio Server Explorer for GUI based interactive access to a Microsoft SQL Server database. Populate a table with data from an Excel worksheet. Use Visual Studio Server Explorer to: Create database tables. Insert new rows into tables. Retrieve and display table data. Modify existing data.

3 The allman server has problems in Visual Studio Sever Explorer. Let's use the local DB server that is installed along with Visual Studio. Create a folder at the root of your C drive to hold files that we will use in the Server Explorer. C:\db USF Resources

4 Using Visual Studio for Databases Visual Studio includes database access functions. Start Visual Studio View "Server Explorer" Set up a Data Connection to the local DB server as shown on the following slides.

5 Adding a Data Connection in Visual Studio Right click on Data Connections and select Add Connection.

6 Adding a Data Connection in Visual Studio You will see this the first time you add a data connection. Select Microsoft SQL Server and click Continue.

7 Adding a Data Connection Click here (LocalDB)\v11.0

Testing the Connection 8

The Data Connection 9

You might need to set an option 10

Select Table and Diagram Options 11 Uncheck this Under Database Tools

12 Adding a Table We will add a table to the database. Populate the table with data from an Excel spreadsheet. Define the table in Visual Studio. Download the table data as a CSV file. Insert the file data into the database table

13 Data Types As we define the new table we will have to specify the type of each column. Common SQL Data Types int nvarchar(n)n = max number chars nchar(n)n = number chars decimal (p,s)p = total number of digits s = number decimal places datetime Many more! nvarchar and nchar are Unicode characters

Download Addresses.csv 14 Download file Addresses.csv from the class web site to the directory that you created on your C:/ drive. Downloads/122_MS_SQL_Server/ Downloads/122_MS_SQL_Server/ Double click on the file to open in Excel.

15 The Addresses Table We will create a new database table to hold the addresses in file Addresses.csv.

Adding a Table Right click on Tables and select Add New Table. 16

Set Table Name in T-SQL Tab 17

Define the Table 18 Click Update to add the table to the database.

Update the Database 19

Table "Addresses" is Now Present 20 Right click on Tables and select Refresh.

21 Viewing Table Data Right click on Addresses and select “Show Table Data”.

22 Viewing Table Data Table is currently empty.

Import Data Let's import the data from Addresses.csv Right click on the connection and select New Query. Query: BULK INSERT Addresses FROM 'C:\db\Addresses.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) 23

Execute the Query 24 Click here to execute

Command Successful 25

Check the Data in the Table 26 It may take some time for the data to appear.

Table Addresses 27

28 The SQL Language The following slides demonstrate SQL commands using Visual Studio Server Explorer. Remember SQL is used everywhere we interact with a database server: Database management programs Command line Our own programs

SQL Commands in Visual Studio We can use Visual Studio Server Explorer to issue arbitrary SQL commands to the server. Right click on Addresses and select New Query 29

New Query 30

SELECT * FROM Addresses 31 Click here to execute the command.

Query Results 32 Results appear below the Query window.

Subset of Columns 33

Retrieve Specific Entries 34 Find all addresses with zip code 33707

Wildcard Selection 35 Find all addresses with last name beginning with S

Wildcard Selection All addresses with last name containing an S 36

37 Case Sensitivity SQL commands and keywords are not case sensitive. Data is case sensitive Characters are stored as upper case or lower case. Sorting order is a mode. Default is “not case sensitive.” Changing is complicated. 4d2d-82ee-588f4f055d30/change-sql-configuration-to-case-sensitive 4d2d-82ee-588f4f055d30/change-sql-configuration-to-case-sensitive Search comparisons same as sorting order. Default is “not case sensitive”

Search for ‘Adams’ 38

Search for ‘ADAMS’ 39

Search for ‘adams’ 40

Sorting the Output 41 Zip_Code is a string. So sort is lexicographic, not numeric. Scroll down to bottom.

Sorting by Zip Code 42 Zip codes are sorted legicographically, not numerically.

Counting Rows How many addresses are there with zip code 33707? 43

Updating Records 44 Suppose Ronald Araque’s zip code should be

Updating Records 45 Note importance of having a unique ID field.

Updated Record 46

Updating Multiple Fields 47 Suppose the Alfonsos have moved.

Updating Multiple Fields 48

Updated Record 49

Deleting a Record 50 Suppose the Andersons have left the club.

Deleting a Record 51

After the Delete 52

Adding a Record 53

Record Added 54

55 Learning SQL Textbook, Chapter 12 Many books available One that I recommend: Teach Yourself SQL in 24 Hours (Fifth Edition) Ryan Stephens, Ron Plew, and Arie Jones, SAMS, 2012 Lots of information on the web A sampling: