Monday, May 18, 2009

Create a database in Visual Basic 2008 Express

One of the biggest things I had to learn was setting up the database. There are LOTS of resources on the web with regard to Visual Basic and how to create databases. But I had great difficulty figuring it out for myself. I now present to you - the result of my searching, trial and effort, and results.

After creating a project, Go to the Solution Explorer. Right-Click on the project name (Bold title above everything else) choose 'Add' then 'New Item'. Choose 'Service-based database' and give it a name (db works, or mydb or something like that). Then click on 'Add'. It will work on it - be patient. It will then bring up the 'Data Source Configuration Wizard' asking you to 'Choose your Database Objects'. Skip this step for now by clicking on 'Cancel'. I learned that I need to setup my database before I create my datasets. This will save steps later. In your solution explorer, you will now see your new database as 'name.mdf'. This is where the information will be stored.

Now to define a Visual Basic database. Click on 'View' 'Database Explorer'. You should see your db file under 'Data Connections'. Click the plus sign next to the database name, then click the plus sign next to Tables. You should note the icon change from a red 'x' to a black plug-in on your database. This means you are now connected to the database. Right-Click on 'Tables' and choose 'Add New Table'. You now define the name of each column and what type of value that column will be and if you will allow that column to be empty on any given row.

Name the column 'CatID' (for Category ID). The Data Type should be 'int' and the Allow Nulls value should be cleared. The second row (which is defining a second column) can be named 'CatName', the type is 'nvarchar(30)' and the Allow nulls should be cleared. By clearing the checkbox under 'Allow Nulls', you are telling the table that some value MUST be in that column for EVERY row. Make one more column named 'CatDesc', with a type of nvarchar(250) and select the 'Allow Nulls' checkbox. This allows the category to have no description, which is ok. Lastly, setup an autoincrement and Primary Key. To do this, first, right click on the StoreID grey block to the left. Chose 'Set Primary Key'. You'll use that later. To setup auto increment, go to the 'Column Properties' and click the plus sign next to 'Identity Specification'. Double click the '(Is Identity) value of 'no' to change it to 'yes'. This will define each row of this table (as you add them) as a new identity with a unique ID number. Essential for later use.

That's it - the table is defined. Now to save it, go to the properties and change the '(Name)' field to 'CatTable'. Close the table definition by clicking the 'x' in the top right corner. Visual Basic will ask you if you want to save changes to 'Table1'. Even though that's not the name you entered, it's talking about the same table. Click 'Yes'. Notice that the new table is listed under your database name.

Now add some data to the new table by right-clicking on the new table name and choose 'Show Table Data'. You will be presented with the column Headings you created. You can't change the ID field because you set it to auto increment. But enter data into each of the other fields, Name and Desc. Note that the Name is required, the Description is not. Tab past the last field and you will enter the next line. Enter a few rows of data. Close the Table data to save.

There you go. The database is created, the columns are defined, and you entered some new information. That wasn't so hard. Now to use that information, to view it, edit it and update/save it - that's a whole 'nother story.

Learning Visual Basic 2008 Express

I'm working on a project. I'm learning Visual Basic 2008 Express Edition. No, 'learning' isn't the project, it's an evil I must conquer so that I can work on my project. I'm building what should be a pretty simple inventory control type program for personal use.

So, as I am learning Visual Basic 2008 Express Edition, I'm climbing the learning curve and doing my best to find answers, tips and tricks. At the beginning, it was very, very difficult for me. I am a fairly seasoned Perl programmer with plenty of personal apps I've enjoyed for many years. But Visual Basic isn't like Perl. Visual Basic is an Object Oriented Programming language. This is very different to me.

Many, many years ago, I studied Computer Science at BYU-Idaho (then called Ricks College). I recall a class or two on Object Oriented Programming and I recall not doing very well. So when I began reading about Visual Basic (which I have never used before), the words 'constructors', 'methods', 'subs', 'overloaded', and 'encapsulation' brought back some 'less-than-stellar' memories.

But I'm pushing through all that with the goal of developing my first Windows Application for my personal use. I'm planning on blogging about some of the things I learn and hopefully, make it possible for others to find answers faster than I did.

Thursday, May 14, 2009

Message Board Game

On message boards, a game to play is sometimes called 'Finish My Sentence'. I posted one to our family web messaging board and here is the result. The change in bold is one poster to the next for a total of 36 entries.


Yesterday was a very good day because it was our second to the last weigh-in. I am excited for girls camp to get here. This planning stuff is certainly a test of endurance. But things are going great because I'm skinny and happy. I love to eat at Taco Johns because I can't get enough of the potato oles. I am so tired of being tired all the time. Sometimes I just really wish money would grow on trees.

Life would certainly be easier if
there was more time to spend playing with the kids and working on projects I want to work on. I think I'll go make some lunch. I want to have Taco Johns (thanks James!) but I can't because I'm painting walls and if I can't get this network problem figured out and fixed I just might burn my tongue on this cheese quesadilla because I'm not waiting for it to cool down. It's ok though because my knee hurts and I just downed 4 Ibuprofen. It's always good when life throws you a twist - keeps you hoppin'.

I'm going to take the domain server off the network to
cheat on my diet today. Sometimes I just can't put off doing the laundry any longer. My feet are cold and I hate telemarketers. I wish they'd all go jump into a big vat of marshmallows. No idea where you might find one. Ugh - it isn't working and I think chocolate might help. Maybe I'll fix me up a nice hot bubblebath. However I need to figure out dinner. When did that become a necessity?

I still haven't had the opportunity to sleep. It's that time again that I get to go home. If I get one more call from work, asking me to come in early tonight, I will just go get my brakes fixed. It always amazes me that I still haven't gone to bed. All I want is sleep and if these pants would let me breath I'd consider that I was as skinny as Dave and Jenn right now, but sometimes I just don't want to do anything. It makes me feel FANTASTIC that the house is getting done!! Now, if only I could remember why yesterday was so good.

The end.

Friday, May 8, 2009

Tough days at work

It has been a couple of tough days at work recently. As the IT Administrator, it is my responsibility to keep the computers maintained and the network up and running. I troubleshoot issues that arise and document all that I do for the next person who has this job.

The last few days (weeks?) have been particularly difficult. It start with Beetle (our computers are all named after vehicles). The user was have lots of trouble with Outlook hanging and crashing and not sending out email. Turns out - that was nothing compared to the last few days.

Over the last 2 weeks, more and more computers are experiencing the same issues. Outlook fails to connect to the mail server OR goes offline after a send/receive. Either way - it's bad.

I wish I had an answer, but so far, it's been impossible for me to find the answer. After lots of troubleshooting on several machines, I have determined that this is an internal network issue. The printers (which are installed on the domain) are getting 'lost' and that crashes Word and Excel. Outlook continues to fail to connect.

So I have decided that the issue is coming from the network switches we use in the utility room to connect everyone together and back to the VPN/Firewall and out the modem. Some time ago, notably prior to the issues at hand, we added a second, stacked switch for more capacity. Our initial 24 port switch was full and we were still adding computers and offices. The two seemed to be working fine, but then these issues starting showing up. I upgraded the firmware on the switches and watched the logs. Nothing terribly useful and the issues continue.

But today I take a new approach. Let's assume it's the second switch. So I took all the lines off the second switch and disconnected the connecting HDMI cable. I am using a small box switch temporarily. Now it's a waiting game. If the issues disappear, maybe I have found the answer, otherwise - more troubleshooting is on its way.