Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45.

Similar presentations


Presentation on theme: "Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45."— Presentation transcript:

1 Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45

2 MSSQL Microsoft SQL is almost identical to MySQL Limiting result count MySQL: Limit # //at end of query MSSQL: Top # //after SELECT Table name/fields MySQL: wrapped in backticks ` MSSQL: wrapped in square brackets [ ] Most of the other differences aren’t needed in what we are doing in this course

3 MSSQL Log in to GoDaddy and get to the Database screen Add New Database Type: Microsoft SQL Server Create a DB user and password, make a note of these for use in our application Click on Webadmin next to the MSSQL database This will open a tool called myLittleAdmin that GoDaddy offers for managing the MSSQL database

4 Tables Unfortunately, there is an issue with the way GoDaddy has this tool set up, and the GUI table builder is not available On left hand side, click on “Tools” and then on “New Query” Use the following query to create a table (you can modify this slightly when you are ready to create a table for your lab)

5 Tables CREATE TABLE [example]( [id] [int] IDENTITY(1,1) NOT NULL, [first] [varchar](50) NOT NULL, [last] [varchar](50) NOT NULL, CONSTRAINT [PK_example] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

6 Tables Now that the table is created, we can use the GUI environment to insert a row and look at the contents of the table

7 VS2013 Now we need to add our connection string to our application web.config file Inside of the tags add the following:

8 VS2013 I’m going to create another page with just two text fields to gather the first and last name for our insert query Go ahead and add the require validators to both I will also set up a button and an onClick function In C# we need to include try/catch blocks around most of our query commands to catch any possible exceptions

9 Connect SqlConnection conn = new SqlConnection( ConfigurationManager.ConnectionStrings[“connectionString Name”].ConnectionString); try{ conn.Open(); OutputLabel.Text = “Connected”; conn.Close(); conn.Dispose(); }catch(Exception ex){ OutputLabel.Text = “Failed to connect” + ex.Message; }

10 Insert conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = “INSERT INTO example (first, last) VALUES (‘’”+first.Text+”, ‘”+last.Text+”’)”; try{ cmd.ExecuteNonQuery(); outputLabel.Text = “Insert Success”; }catch(Exception ex2){ outputLabel.Text = “Failed insert” + ex2.Message; } conn.Close();

11 GridView There are several ways to output content from a database To get some raw output on the page, we are going to use the GridView control from the Data section in the toolbox We can do all of the configuration for this control from the smart tag in the split screen view

12 Publish Site Now that we have tested all of our pages and features, we are ready to publish the pages to our web server In a web application project like the one we have built, the files we need to upload are all of the.aspx,.master, and the.dll files in the bin folder GoDaddy is set up to run PHP and.NET in the same site, so I’m just going to add a folder to our existing site for the.NET application

13 Web Site vs Project From the File menu, we can create a Project like the one we did together, or we can create a Web Site In a project, our code is compiled into the.dll file we had to upload earlier In a Web Site, the code is not pre-compiled, so we would have to upload all of the site files, but there wouldn’t be a.dll file

14 Web Site vs Project There are pro’s and con’s to both approaches For content with complex code, having it precompiled can produce a better response time, as the server doesn’t have to compile the page when it is requested For a web site, you can edit the code behind file directly on the server, and on the next page load, you will see the changes Having the site precompiled into a.dll can make it a little more challenging to recreate the code files in case the original project is lost, but not impossible

15 Lab 6 – C#/MSSQL Due: Nov 5 Create a simple web form in C#.NET Minimum: 2 Text Fields, 1 Drop Down (include a blank option), 2 Radio Buttons grouped together, 3 Checkboxes, 1 Submit Button Create a MSSQL DB and Table to store the form submissions Ensure the form is properly validating all fields before inserting the data into the DB Output an HTML table containing the values in your DB table

16 Lab 5 - AJAX I’ve gotten several questions about the AJAX lab You need to create 2-3 pages Page 1 should have at least two AJAX calls on it Page 2/3 should be the pages called by the AJAX and return data in HTML format and JSON format When returning data in JSON format, ensure there are no HTML tags showing up on the page (doctype, head, body, etc) If you want to try something other than DB interaction, you can try out uploading a file through AJAX as an alternative to one of the two calls mentioned above

17 Next Week Next Week we will be looking at using 3 rd party APIs, such as Google Maps, Calendar, Facebook, etc Reminders: Lab 5 (AJAX) is due Today Lab 6 (C#) is due on Nov 5 th Project 2 is due on Nov 5 th Term Project is due on Dec 10 th


Download ppt "Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45."

Similar presentations


Ads by Google