MDBitz - Matthew Denton
SEO
Let me put this as clearly as possible. A domain that forwards to an existing site does not provide any Page Ranking benefits to the forwarded domain. In fact the domain name that forwards to the existing website will not even be available in Search Engine Result Pages (SERPs). This is because when you do a forward you are informing Google, Yahoo, Bing, and other Search Engines that this site does not have any content but instead the site exists at the forwarded domain and that should be indexed. The only time when a fowarding domain assists in the Page Ranking of the forwarded domain is when you migrate a website to a new main domain as the Page Ranking will be associated with the new domain instead of starting off as a new website.
If you are looking to increase your Page Ranking within Search Engines the main factor you should focus on is writing unique and worthwhile content. Don’t get sucked into the whole keyword feeding frenzy. Yes you should include terms that are relevant to your content but only if they make sense in the context of your content. If you do buy multiple domain names do so only to secure those domains with the purpose of stopping competitors from buying and using them.
Forwards, Page Ranking, Search Engine Optimization, SEO, URL Forwarding, URL Redirects
Ever find yourself working in an unfamiliar Database or table and in need of knowing what are the data types for the different columns? Well that recently happened to me when I had to expand some queries in a DB2 environment.
As it turns out there exists the Describe command that outputs the columns of a table and their data type. The basic command is as follows that can be used on a TABLE or VIEW:
DESCRIBE TABLE schema.table_name
The command will output the following information for each column.
- Column Name
- Type Schema
- Type Name
- Length
- Scale(precision)
- Nulls(is nullable)
In addition to obtaining the column information you can also use the command to get a table’s indexes.
DESCRIBE INDEXES FOR TABLE schema.table_name
Resources
Column Data Type, Column Type, DB2, DESCRIBE, DESCRIBE TABLE, IBM, SQL
A common task when creating a form based windows application is to allow a user to save their information and to also load saved information. In this short tutorial I will show you the basic steps to save a form’s information to a file and then load up the contents of the saved file.
Saving a Form’s Data to a File
The process for saving data to a file is pretty straightforward in Visual Basic. They include opening up a writer to a specified file, writing the contents, and then closing the writer when completed.
- Define and open your File Writer
In this case we will utilize the StreamWriter class of the System.IO package. I will assume for these instructions that you have imported the System.IO library.
Dim FileWriter As StreamWriter ' define the stream writer
' Open the File for writing
FileWriter = New StreamWriter("c:\temp\sampleFile.txt", False)
- Write the desired data to the file
To write data to the file you can utilize the WriteLine function. In the case of forms you may want to write different data. For a text field saving the Text is appropriate while when using a check box or radio button you will want to save the Checked property.
' Save Component values
FileWriter.WriteLine(textBox.Name & "|" & textBox.Text)
FileWriter.WriteLine(comboBox.Name & "|" & comboBox.SelectedIndex.ToString())
FileWriter.WriteLine(radioBtn.Name & "|" & radioBtn.Checked.ToString())
- Close and Save your data to the File
To complete your write you simply need to call Close on your writer. However if you want you can first call Flush to have the data written out. This step is optional however as the Close function will call Flush if needed.
' Save and Close File
FileWriter.Flush() ' optional as close will flush
FileWriter.Close()
Reading Data from a File
The process for reading information out of a File is similar to the writing process. First you want to open up the file, then you want to read a line of data, single character, or etc depending on how you are going to process the data until you reach the end. After you have read all the data you would lastly close the File.
- Define and open your File Reader
In this case we will utilize the StreamReader class of the System.IO package.
Dim FileReader As StreamReader ' define the File Reader
FileReader = New StreamReader("c:\temp\sampleFile.txt", False)
- Iterate until the End of File is reached
Do Until FileReader.EndOfStream
' Processing Code goes here
Loop
- Read in and Process the File’s data
In the below example we will read in the file’s contents 1 line at a time. To see the full example of how the data is processed please view the full source code below.
'Read the next line
prop = FileReader.ReadLine()
- Close the File Reader
After the loop close the FileReader as all the data has been read.
A complete sample Save and Write Class
For those that learn better by example below is a Simple Class that holds a complete example of saving data to a File from a Form in addition to loading the saved data from the form and setting the components to the correct state. The example contains basic error checking including validating that the saved file exists, however it does not validate the data in the file is of the correct format and not corrupted.
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
loadSavedData()
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
Close() 'Close Application
End Sub
Private Sub LoadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadButton.Click
loadSavedData()
End Sub
Private Sub loadSavedData()
Dim FileReader As StreamReader ' define the File Reader
Dim prop(2) As String ' define array of length 2
' Test if the Saved File exists
If File.Exists("c:\temp\sampleFile.txt") Then
'Open the File for reading
FileReader = New StreamReader("c:\temp\sampleFile.txt", False)
' Continue until EOF reached
Do Until FileReader.EndOfStream
'Read the next line and split its value based on the | character
prop = FileReader.ReadLine().Split("|")
' If TextBox Component set it's property
If String.Equals(prop(0), textBox.Name) Then
textBox.Text = prop(1)
' If ComboBox Component set it's property
ElseIf String.Equals(prop(0), comboBox.Name) Then
comboBox.SelectedIndex = Integer.Parse(prop(1))
' If RadioButton set if checked
ElseIf String.Equals(prop(0), radioBtn.Name) Then
radioBtn.Checked = Boolean.Parse(prop(1))
ElseIf String.Equals(prop(0), RadioButton1.Name) Then
RadioButton1.Checked = Boolean.Parse(prop(1))
ElseIf String.Equals(prop(0), RadioButton2.Name) Then
RadioButton2.Checked = Boolean.Parse(prop(1))
End If
Loop
' close the file
FileReader.Close()
End If
End Sub
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
Dim FileWriter As StreamWriter ' define the stream writer
' Open the File for writing
FileWriter = New StreamWriter("c:\temp\sampleFile.txt", False)
' Save Component values
FileWriter.WriteLine(textBox.Name & "|" & textBox.Text)
FileWriter.WriteLine(comboBox.Name & "|" & comboBox.SelectedIndex.ToString())
FileWriter.WriteLine(radioBtn.Name & "|" & radioBtn.Checked.ToString())
FileWriter.WriteLine(RadioButton1.Name & "|" & RadioButton1.Checked.ToString())
FileWriter.WriteLine(RadioButton2.Name & "|" & RadioButton2.Checked.ToString())
' Save and Close File
FileWriter.Flush() ' optional as close will flush
FileWriter.Close()
End Sub
End Class
Close, File, flush, IO, Read, Save, VB, Visual Basic, Write
Like most individuals I find the built int SUM function of SQL very helpful when performing computations. Recently however I found myself wondering how to compute the product of a result set grouped by some factor, and I found myself slightly at a lost as no Product function exists.
Fortunately for us we can use some basic Math to do our aggregate multiplication. As you may or may not remember we can Log and AntiLog to perform multiplication.
X * Y * Z = ANTILOG( LOG( X ) + LOG( Y ) + LOG( Z ) )
Looking closely at the above formula you can see that these functions all exist in most Database Servers and in T-SQL specifically you can rewrite the formula as :
SELECT EXP ( SUM ( LOG (myColumn) ) ) FROM myTable
If you wanted to get even fancier and get totals based on some criteria then you could add in GROUP BY and WHERE clauses to your queries. For example lets say you are doing some probability calculations and want to have the product of some percentages then you could do something like:
SELECT EXP(SUM(LOG(r.MEAN)))
FROM RESOURCES r
WHERE r.MODEL_ID = "TEMP"
GROUP BY r.GROUP_ID
ORDER BY r.GROUP_ID
Also it is worth wild to mention this only works for positive values. If you want to have the product of values that could potentially be negative you will have to keep track of the number of negative values and then set the result as necessary.
ANTILOG, EXP, log, Product, SQL, SUM, T-SQL