Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
For this movie, I need to run Visual Studio as an administrator. Let me show you how to do that again. I am going to go to my Start menu, find my shortcut to Visual Studio, right-click on it, and choose Run as administrator. Now that I'm inside Visual Studio, I need to open a project, by going to File > Open > Project/Solution. Go to your Exercise File folder > Chapter 2 > Movie 7 and then open the Server Explorer folder and then load the ServerExplorer.sln file and click Open.
The Server Explorer lives over here on the left side of the screen. It provides a way to explore hardware resources on your local computer. And if you are on a network, it also permits access to computers and services on remote computers. You can see, in my Server Explorer, one computer, which is the local computer. If I expand this node, you'll see several sections. There is the event logs, the management classes, messaging queues, and many more. I am going to show you today the Event Logs and the Data Connection section.
There are lots more to explore in here, however. Let's start with the event logs. The event logs exist in Windows to allow applications to store information about what's happening as they are running. If I expand his node, you will see the different kinds of event logs. I'm going to work with the Application event logs. When I open this up, you'll see each application listed here, and if I open up one of these--let's say this one done here called Desktop Windows Manager-- you'll see that there are a number of events that have been logged over the last couple of days.
I'm going to write my own event items into the event log. I've already got a node from earlier today called Essential Training. I am going to write to that note. Let me show you how easy that is to do. First, I'm going to take this application log, and I am going to drag it over and drop it on the designer surface. When I do that, Visual Studio adds an item to this Component Tray down here at the bottom. Let me close this Output window here.
Next, I'm going to write some code on a button click event. So I need to open my Toolbox, find the Button control, drag it to the designer surface, and then to write the code, I am going to double-click on this button. This is a Visual Basic application, so I need to write a couple of lines of Visual Basic code. I'll start by naming my source for the event log. I'm going to call it Essential Training, like that.
Then on the next line of code, I'm going to write to the log file itself. I'm going to say, "Hello log." Then I'm going to type a comma, and here I'm going to use EventLogEntryType, and here I get to pick the warning level. Is it an error, a warning, a piece of information? I'm going to chose Error.
So let's review what I did again. I wrote a piece of code for the button click procedure. I told the event log I am going to be writing something into a log called Essential Training and then the actual data that I wrote was a string "Hello log", and this is the type of log entry. It's an error entry. I'll run the application now by pressing F5. Then I'll click on the Button. After a few seconds, I'll close the application. And then I'm going to go look in the Event Log.
I can use the normal Windows Event Log viewer, or I can go to Server Explorer, find the Essential Training section and open that up. As you can see, I have three entries. You're going to have more or less than I do, depending on how often you've run your demos. I've already run some demos earlier today when I was setting up this computer, so you can see that at 3:57 this afternoon I wrote a test in there, and here is the one we just wrote a few minutes ago: Hello log. Another favorite of mine in the Server Explorer is the Data Connections section.
This allows me to add connections to databases. Let me show you how easy that is. I'm going to click here, Connect to Database. I get to pick the kind of database I am going to connect to. For today's demo, I am going to use a SQL Server database file. I am going to click on Continue. I am next asked what information is required to find that file. I need the file name, and I need a login credential. So I'm going to start by clicking on Browse.
In your Exercise File, on your desktop, is an Assets folder. Inside that Assets folder is a northwnd database file. It ends with an MDF extension. You may or may not see this extension, depending on how you've got your computer configured. I'm going to click on northwnd.mdf and click Open. Then I am going to click the Test Connection to see if I have permissions to talk to this database, and I do.
Next, I'm going to click on OK, and after waiting a few seconds, a new connection shows up in Server Explorer. Now without having to leave Visual Studio, I can open this node and look at the structure of my database. For instance, here are all the tables inside the database. Here are the stored procedures that are inside the database. When I have a table, I can click on it and learn more about its structure.
This shows me the number of fields that are part of the table. I can right-click and choose Show Table Data to actually talk to the database and see the data that's stored inside that file. On several of the movies in this title, we'll be looking at this database. The Server Explorer exists to let me look at my local computer and other servers on my network and discover information about the computer itself and databases that are out there available for me to use. It's a great tool.
I suggest you check it out.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97398 Viewers
61 Video lessons · 84633 Viewers
71 Video lessons · 68840 Viewers
56 Video lessons · 101296 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.