Wednesday, September 3, 2008

Internet Explorer 8 Beta Won't Support Logmein

I tried IE8 - why not? Logmein refuses to work. It claims that all computers you are trying to access are "in a previous session." I witnessed a workstation with IE7 NOT have the same problem.

Of course, Google Chrome does not support ActiveX, so here we are going back to IE7.


Monday, September 1, 2008

Visual Basic Express 2008

Due to the virus (see last two postings), I had to download VS and install again. Due to potential inavailabilty and my lack of desire to search past the obvious, I downloaded and installed Visual Basic Express Edition 2008 instead of 2005. Project conversion went rather seamless - no issues. Environment looks the same. It appears to be a rather friendly version change.

I am sure that some Microsoft developer would vomit reading this as there invariably are plenty of major changes under the hood. We will see when I find them....

Friday, August 29, 2008

Perceived Death of a Thumb Drive

I purchased a 4GB USB thumb drive two days ago. Working fine on both PCs (the corrupt one - see prior post and the backup).

Suddenly, neither computer can access it. Windows provides a drive letter, but when you try to open it, you get a "Insert disk into Drive E" message.

I formatted it in Computer Management--> Disk Management area, and voila! it works now.

I made the mistake of leaving it in the USB port while reformatting my C drive due to Windows installation. Perhaps the sequence through Windows (I wiped all partitions - perhaps the system saw this one) or the constant restarts. At any rate, at least it works now.

Disappearing Network Connections - XP Pro

I was working on my laptop and poof! all of my network adapters and network connections suddenly disappear. VPN adapter, USB to Ethernet adapter (docking station), NIC, Wi-fi, all Deterministic Network Enhancers, etc. Gone.

I do the classic warm and cold restart. No change.

I try to "create" a network connection. No option.

Follow Window's suggestion: uninstall driver, allow PnP to detect device, and reinstall. Can't uninstall drivers due to the system 'needing them to start up' (no they don't - a VPN software adapter to start? Never.)

I do a Windows XP repair installation. The only change is that I can now uninstall the driver, but the reinstall process proclaims a driver INF problem.

I download new drivers from Dell. Run through installation. "Problem installing new drivers." Right.

Search for this peculiar error on forums. Find that there is an MSDN article on the needed steps to have networking in XP. Go through various services (find that some are stopped), start them. No change. Article suggests to verify that "Simple TCP/IP Services" are installed in Windows Components. They are not. Try to install. Error.

I search the forums. Similar issue. Try sfc /scannow. Try an "Upgrade" Installation of XP. No change.

Alas, I had to reformat the entire drive. Per the forums, this is caused by a virus. Ironically, this disappearance of the connectivity occured while the AV was scanning.....

Forum posting here: http://forums.devshed.com/windows-help-34/network-card-won-t-install-due-to-internal-error-505183-2.html

Sunday, August 24, 2008

Issues with IsDBNull and MySQL Varchar Fields

This one is bizarre - I am not sure if the issue lies in with the .NET framework or MySQL.

Opening a DataReader on an Odbc connection type in VB.NET allows for the verification of null fields with the .IsDBNull function. However, in one instance, I was absolutely certain that a MySQL field was null (I had just created it), yet I kept getting a .NET error in the program when I tried to verify the null status. I checked and checked and tried many different things. I was using a VARCHAR(45) field and I noticed that most of the DB fields used were VARCHAR(250). Hence, I took a shot in the dark and changed the field to VARCHAR(250). The problems went away.

I still am not sure if this is a .NET or a MySQL error, but it was frustrating and bizarre to say the least.

Monday, August 18, 2008

Connecting to a SQL Database from Excel

First of all - WHY would anyone download data directly from a SQL database into an Excel spreadsheet on an automated basis? The simple fact that I am writing this indicates that someone needed it....but I think the idea is just silly.

1.: Create the necessary trigger (button) and double-click in design mode to start entering code.

2. Paste the following code into the beginning of the sub routine.
Dim dbs As Database
Dim rs As Recordset
Dim vtSql As String
Dim numberOfRows As Integer
ThisWorkbook.Activate

3. In my case, I read from the data in rows A12 through A30 and fed this into the SQL statement
''Open the database
For i = 12 To 30
'Get value from user
a = Me.Range("A" & i, "A" & i).Value
'If value is blank, skip processing
If a = "" Then GoTo 100
'All the fun database stuff
Set dbs = OpenDatabase("ENTER NAME OF OBDC DATA SOURCE NAME HERE", False, True, "ODBC;Regional=Yes")vtSql = "ENTER SQL STATEMENT HERE"
Set rs = dbs.OpenRecordset(vtSql)
'Drop data back onto the spreadsheet
Me.Range("B" & i).CopyFromRecordset rs
dbs.Close
Set dbs = Nothing
Set rs = Nothing
100
Next i

Wednesday, August 6, 2008

Relating VBA Function Output to Another Table in MS Access 2003

It is a functional limitation of MS Access. You cannot relate the output of a VBA function, displayed in a query, to data held in another table.

Hence, this presents a unique problem. In my case, I should just be using a SQL Server, but the project is going to be handed over to everyday users and the budget for it does not afford a customized front end.

I was trying to take a variety of dates held in field of records in Table 1, use a VBA function to round up the date to the 1st of the next month, and relate those dates to a date field in Table 2. Table 2 contained other data that I needed related to the transactions in Table 1.

Since I can't forge that relationship, I ended up having to make this MORE complex on a SIMPLER program to accomplish.

I developed a MS Excel spreadsheet, put in 30 years of dates (= A1+1 method), and then used an Excel function to round the dates up. I then imported this into MS Access as Table 3. The individual dates in Table 3 related to the dates in Table 1. The rounded up dates in Table 3 related to the 1st of the month only dates in Table 2.

There you have it - silly, but it works.

If you want a copy of the file, email me.

Saturday, August 2, 2008

How to Integrate SQL Database Content with Quickbooks

Published as an article on Google's knol service.


http://knol.google.com/k/garrett-fisher/how-to-integrate-sql-database-content/2y7bdb9ql4zr1/4#

Friday, August 1, 2008

How to Integrate Flying J Truck Stop Scanning with your System

I just wrote a Knol article on this subject. Try this link, if it does not work, paste the title of this blog posting into the search box at knol.google.com.

http://knol.google.com/k/garrett-fisher/how-to-integrate-flying-j-truck-stop/2y7bdb9ql4zr1/2#

Thursday, July 31, 2008

Sending an SMTP Message

Well, I make frequent mention of this inability to find easy code to send an SMTP message, but ironically I have not yet posted any source code on the matter. Here she is.

First, put the following in your declarations area:

Imports System.Net.Mail

Second, declare the appropriate objects.

This declares the message itself
Dim msg As New System.Net.Mail.MailMessage
‘This declares the SMTP-related items object
Dim smtp As New System.Net.Mail.SmtpClient
‘Declare the From Address
Dim addrFrom As New System.Net.Mail.MailAddress("Insert your from address here")
‘Declare the email address for the recipient – you can add more than one recipient – just keep declaring
Dim addrTo As New System.Net.Mail.MailAddress(“Insert recipient address here”)

Third, the code.

‘Assign objects to MailMessage
msg.From = addrFrom
msg.To.Add(addrTo)

‘If you want an attachment – use this line. Repeat as necessary.
msg.Attachments.Add(New Attachment(“Insert File and Path”))

‘Subject to Email
msg.Subject = “Subject”

‘Body Contents
msg.Body = “Body”

‘Server Settings, Etc (NOTE: I use My.Settings. Replace with your contents as needed)
smtp.Host = My.Settings.Server
smtp.Port = My.Settings.Port
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New System.Net.NetworkCredential(My.Settings.Username, My.Settings.Password)

‘And, send the message
smtp.Send(msg)

My standard disclaimer is that you should have Try/Catch statements in case you receive errors attempting to send.

On a side note, I did point to an Exchange server that had an SMTP connector installed and it worked the first time without a hitch.

Saturday, July 26, 2008

New Blog Title

So soon? Yes - within a week I am changing the title. I chose not to restrict this blog to solving the void of simple programming advice to VB.NET as the problem seems to be just a programming thing - regardless of the language. I have already come across other issues dealing with ASP & ASP.NET- so its best to nip the nomenclature issue in the bud. Hence, as I journey down roads driven by client needs and have to cross new bridges, I will share my solutions to frustrations as I find them.

Thursday, July 24, 2008

'The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified.'

"The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again"

This problem occurs in Visual Studio 2005 Express (VB). Of course, if you do any searching on the error, you will find that many programmers experiencing this problem didn't change anything. Neither did I. I followed the suggestion of rebuilding project. Didn't work. Tried commenting out specific problem. Didn't help. Commented out problem line (property irrelevant and set via user settings from My. Settings) and restarted VS. Designer opened fine.

I don't know why - but it seems many others on the forums don't either. At least give the easy trick a try.

Download File via FTP in VB.NET

This is another shocking lack of .NET - easy FTP. While version 2.0 of .NET does in fact have native FTP handling capabilities (WinHTTP), it is for a lack of a better word, a pain - especially when you are trying something simple. If you are building a commercially distributed, mission-critical, or enterprise class application, you probably will find it valuable to go through the extra steps to use native functionality. However, if FTP is a relatively quick need, this has my recommendation.

I searched high and low for an easy way to do this. There are plenty of complex methods, controls available for sale, and outdated methods to accomplish a simple FTP download. The simplest way to do so (and have it working by lunchtime) is to use the edtFTPnet control available at http://www.enterprisedt.com/products/edtftpnet/overview.html. It is free for commercial use under a GPL license. My code sample as below:

First, add the control to your toolbox.
Second, drag the control onto the applicable form.
Third, your code must specify connection characteristics. Sample below:

NOTE: I am referencing My.Settings where the data is stored in the application - you can easily use direct references or assign variables to control the data. Also, I have a setting in My.Settings for ACTIVE or PASSIVE file transfer mode.

FTPConnection1 is the control name.

You can also set these settings directly in the control properties.

'load FTP settings
FtpConnection1.ServerAddress = My.Settings.FTPServer
FtpConnection1.UserName = My.Settings.FTPUsername
FtpConnection1.Password = My.Settings.FTPPassword
FtpConnection1.ServerPort = CInt(My.Settings.FTPPort)
FtpConnection1.ServerDirectory = My.Settings.FTPDirectory
If My.Settings.FTPConnectionMode = "1" Then
FtpConnection1.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.ACTIVE
Else
FtpConnection1.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV
End If

Fourth, the connection and file download code.


FtpConnection1.Connect()
FtpConnection1.ChangeWorkingDirectory("Insert FTP path here")
FtpConnection1.DownloadFile("Insert Where file is going on PC", "Insert File Name on FTP Server")
FtpConnection1.Close()

That's it.

Sunday, July 20, 2008

Why the Blog

Blogging is supposed to be a soap box, right? Lately, I have encountered a shockingly awful lack of simple and direct advice for any level of VB.NET programmer wishing to embark on a programming task that they have never done. You can be the world's top clustered server farm engineer yet have never attempted to email a simple message from .NET. Even with skills and knowledge of that level, you won't figure out how to do it on your own and it would be mightily helpful if direct, concise examples existed with extremely simplifed code.

In the last few months, I have lived the misery of this conundrum. I have been developing a medium-scale application that merely touches on various wide-ranging features. I try to find simple advice and answers on say, sending a very simple SMTP email message, and all I can find are examples on how to write your own version of Outlook with mountains of code to boot. All I needed was to send a message......

Necessity is the mother of invention, so I am committing these findings to writing - hopefully to spare someone else the same fruitless search.