Archive for May, 2008
datatable.select and DISTINCT
Posted by Kelly's Chronicles in vb.net on May 30, 2008
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Dim dsSource As DataSet
Dim dsDest As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dsSource = New DataSet()
dsDest = New DataSet()
‘ Create source table
‘
Dim dt As New DataTable("Orders")
dt.Columns.Add("EmployeeID", GetType(String))
dt.Columns.Add("OrderID", GetType(Integer))
dt.Columns.Add("Amount", GetType(Decimal))
dt.Rows.Add(New Object() {"Sam", 5, 25.0})
dt.Rows.Add(New Object() {"Tom", 7, 50.0})
dt.Rows.Add(New Object() {"Sue", 9, 11.0})
dt.Rows.Add(New Object() {"Tom", 12, 7.0})
dt.Rows.Add(New Object() {"Sam", 14, 512.0})
dt.Rows.Add(New Object() {"Sue", 15, 17.0})
dt.Rows.Add(New Object() {"Sue", 22, 2.5})
dt.Rows.Add(New Object() {"Tom", 24, 3.0})
dt.Rows.Add(New Object() {"Tom", 33, 78.75})
dsSource.Tables.Add(dt)
dg.DataSource = dsSource
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dg.DataSource = Me.SelectDistinct("DistinctEmployees", dsSource.Tables("Orders"), "EmployeeID")
End Sub
‘This method copies unique values of the field that you select into a new DataTable. If the field contains
‘ NULL values, a record in the destination table will also contain NULL values.
Public Function SelectDistinct(ByVal TableName As String, _
ByVal SourceTable As DataTable, _
ByVal FieldName As String) As DataTable
Dim dt As New DataTable(TableName)
dt.Columns.Add(FieldName, SourceTable.Columns(FieldName).DataType)
Dim dr As DataRow, LastValue As Object
For Each dr In SourceTable.Select("", FieldName)
If LastValue Is Nothing OrElse Not ColumnEqual(LastValue, dr(FieldName)) Then
LastValue = dr(FieldName)
dt.Rows.Add(New Object() {LastValue})
End If
Next
If Not dsSource Is Nothing Then dsDest.Tables.Add(dt)
Return dt
End Function
Private Function ColumnEqual(ByVal A As Object, ByVal B As Object) As Boolean
‘
‘ Compares two values to determine if they are equal. Also compares DBNULL.Value.
‘
‘ NOTE: If your DataTable contains object fields, you must extend this
‘ function to handle the fields in a meaningful way if you intend to group on them.
‘
If A Is DBNull.Value And B Is DBNull.Value Then Return True ‘ Both are DBNull.Value.
If A Is DBNull.Value Or B Is DBNull.Value Then Return False ‘ Only one is DBNull.Value.
Return A = B ‘ Value type standard comparison
End Function
Technorati Tags: vb.net,.NET,csharp,DISTINCT,Framework,LINQ,data,limitations,code,DataSet,DataTable,DataSource,Select,DBNULL
Windows Live Tags: vb.net,.NET,csharp,DISTINCT,Framework,LINQ,data,limitations,code,DataSet,DataTable,DataSource,Select,DBNULL
Asynchronous Requests, Threading and Delegates in .NET
Posted by Kelly's Chronicles in vb.net on May 29, 2008
' Here you have a function that already exists. Now you want to' ' be able to run it in a separate thread.' Function RandomFunction(ByVal Param1 As String, ByVal Param2 As Object, ByVal param3() As Integer) As List(Of String) Return Nothing End Function ' So we declare a delegate with a matching signature' Delegate Function RandomFunctionDelegate(ByVal Param1 As String, ByVal Param2 As Object, ByVal param3() As Integer) As List(Of String) ' Create an instance of the delegate that points to our original method' Dim RandomFunctionDelagteInstance As New RandomFunctionDelegate(AddressOf RandomFunction) ' And create a place to store the return value.' Dim RandomFunctionReturnValue As List(Of String) ' Now we can create a simple new method that kicks off the old method asynchronously.' Sub RandomFunctionBegin(ByVal Param1 As String, ByVal Param2 As Object, ByVal param3() As Integer) ' The BeginInvoke() method is part of every delegate.' ' Here we want to tell it what code to run when the method is finished.' RandomFunctionDelagteInstance.BeginInvoke(Param1, Param2, param3, AddressOf RandomFunctionEnd, Nothing) End Sub 'And finally, here is how we know when it finishes and set the return value.' Sub RandomFunctionEnd(ByVal ar As IAsyncResult) RandomFunctionReturnValue = RandomFunctionDelagteInstance.EndInvoke(ar) End Sub
Getting all users from Active Directory using LDAP query
Posted by Kelly's Chronicles in vb.net on May 28, 2008
DirSearcher.SearchRoot = New DirectoryEntry("LDAP://" & System.Environment.UserDomainName)
DirSearcher.Filter = "(&(objectclass=user)(objectcategory=person))"
DirSearcher.PageSize = 1000
DirSearcher.SearchScope = SearchScope.Subtree
‘DirSearcher.PropertiesToLoad.Add("sAMAccountName")
Dim DirSearchResultCol As SearchResultCollection
DirSearchResultCol = DirSearcher.FindAll()
Dim objResult As SearchResult
For Each objResult In DirSearchResultCol
Debug.Print(objResult.Properties("sAMAccountName")(0))
Next
Outlook Data File Crash
Posted by Kelly's Chronicles in Computers and Internet on May 27, 2008
New Addition To Family!
Posted by Kelly's Chronicles in Uncategorized on May 23, 2008
vb.net FTP Class
Posted by Kelly's Chronicles in vb.net on May 23, 2008
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Net.Sockets
Private m_sRemotePassword, m_sMess As String
Private m_iRemotePort, m_iBytes As Int32
Private m_objClientSocket As Socket
Private m_bLoggedIn As Boolean
Private m_sMes, m_sReply As String
‘to the following specified size.
Public Const BLOCK_SIZE = 512
Private m_aBuffer(BLOCK_SIZE) As Byte
Private ASCII As Encoding = Encoding.ASCII
Public flag_bool As Boolean
‘General variable declaration
Private m_sMessageString As String
Public Sub New()
m_sRemoteHost = "microsoft"
m_sRemotePath = "."
m_sRemoteUser = "anonymous"
m_sRemotePassword = ""
m_sMessageString = ""
m_iRemotePort = 21
m_bLoggedIn = False
End Sub
Public Sub New(ByVal sRemoteHost As String, _
ByVal sRemotePath As String, _
ByVal sRemoteUser As String, _
ByVal sRemotePassword As String, _
ByVal iRemotePort As Int32)
m_sRemoteHost = sRemoteHost
m_sRemotePath = sRemotePath
m_sRemoteUser = sRemoteUser
m_sRemotePassword = sRemotePassword
m_sMessageString = ""
m_iRemotePort = 21
m_bLoggedIn = False
End Sub
Public Property RemoteHostFTPServer() As String
‘Get the name of the FTP server.
Get
Return m_sRemoteHost
End Get
‘Set the name of the FTP server.
Set(ByVal Value As String)
m_sRemoteHost = Value
End Set
End Property
Public Property RemotePort() As Int32
‘Get the FTP Port Number.
Get
Return m_iRemotePort
End Get
‘Set the FTP Port Number.
Set(ByVal Value As Int32)
m_iRemotePort = Value
End Property
Public Property RemotePath() As String
‘Get the remote path.
Get
Return m_sRemotePath
End Get
‘Set the remote path.
Set(ByVal Value As String)
m_sRemotePath = Value
End Set
End Property
Public Property RemotePassword() As String
Get
Return m_sRemotePassword
End Get
Set(ByVal Value As String)
m_sRemotePassword = Value
End Set
End Property
Public Property RemoteUser() As String
Get
Return m_sRemoteUser
End Get
Set(ByVal Value As String)
m_sRemoteUser = Value
End Set
End Property
Public Property MessageString() As String
Get
Return m_sMessageString
End Get
Set(ByVal Value As String)
m_sMessageString = Value
End Set
End Property
Return GetFileList("")
End Function
Public Function GetFileList(ByVal sMask As String) As String()
Dim cSocket As Socket
Dim bytes As Int32
Dim seperator As Char = ControlChars.Lf
Dim mess() As String
‘Check if you are logged on to the FTP server.
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command,
SendCommand("NLST")
Else
SendCommand("NLST " & sMask)
End If
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
bytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
m_sMes += ASCII.GetString(m_aBuffer, 0, bytes)
Exit Do
End If
Loop
cSocket.Close()
ReadReply()
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Function
Public Function GetFileSize(ByVal sFileName As String) As Long
Dim size As Long
Login()
End If
‘Send an FTP command.
SendCommand("SIZE " & sFileName)
size = 0
size = Int64.Parse(m_sReply.Substring(4))
Else
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Function
Public Function Login() As Boolean
New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
m_objClientSocket.Connect(ep)
Catch ex As Exception
MessageString = m_sReply
Throw New IOException("Cannot connect to remote server")
If (m_iRetValue <> 220) Then
CloseConnection()
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
‘Send an FTP command to send a user logon ID to the server.
SendCommand("USER " & m_sRemoteUser)
If (Not (m_iRetValue = 331 Or m_iRetValue = 230)) Then
Cleanup()
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
‘Send an FTP command to send a user logon password to the server.
SendCommand("PASS " & m_sRemotePassword)
If (Not (m_iRetValue = 230 Or m_iRetValue = 202)) Then
Cleanup()
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End If
‘Call the ChangeDirectory user-defined function to change the folder to the
‘remote FTP folder that is mapped.
ChangeDirectory(m_sRemotePath)
Return m_bLoggedIn
End Function
Public Sub SetBinaryMode(ByVal bMode As Boolean)
‘Send the FTP command to set the binary mode.
‘(TYPE is an FTP command that is used to specify representation type.)
SendCommand("TYPE I")
Else
‘Send the FTP command to set ASCII mode.
‘(TYPE is a FTP command that is used to specify representation type.)
SendCommand("TYPE A")
End If
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Sub
‘ Download a file to the local folder of the assembly, and keep the same file name.
Public Sub DownloadFile(ByVal sFileName As String)
DownloadFile(sFileName, "", False)
End Sub
‘ Download a remote file to the local folder of the assembly, and keep the same file name.
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal bResume As Boolean)
DownloadFile(sFileName, "", bResume)
End Sub
‘Download a remote file to a local file name. You must include a path.
‘The local file name will be created or will be overwritten, but the path must exist.
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String)
DownloadFile(sFileName, sLocalFileName, False)
End Sub
‘ Download a remote file to a local file name and include a path. Then, set the
‘ resume flag. The local file name will be created or will be overwritten, but the path must exist.
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long
Login()
End If
sLocalFileName = sFileName
End If
st = File.Create(sLocalFileName)
st.Close()
End If
cSocket = CreateDataSocket()
offset = 0
offset = output.Length
‘Send an FTP command to restart.
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
offset = 0
End If
End If
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If
‘Send an FTP command to retrieve a file.
SendCommand("RETR " & sFileName)
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)
Exit Do
End If
Loop
If (cSocket.Connected) Then
cSocket.Close()
End If
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
‘ This is a function that is used to upload a file from your local hard disk to your FTP site.
Public Sub UploadFile(ByVal sFileName As String)
UploadFile(sFileName, False)
End Sub
‘ This is a function that is used to upload a file from your local hard disk to your FTP site
‘ and then set the resume flag.
Public Sub UploadFile(ByVal sFileName As String, _
ByVal bResume As Boolean)
Dim cSocket As Socket
Dim offset As Long
Dim input As FileStream
Dim bFileNotFound As Boolean
Login()
End If
offset = 0
Try
SetBinaryMode(True)
offset = GetFileSize(sFileName)
Catch ex As Exception
offset = 0
End Try
End If
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
offset = 0
End If
End If
‘Send an FTP command to store a file.
SendCommand("STOR " & Path.GetFileName(sFileName))
If (Not (m_iRetValue = 125 Or m_iRetValue = 150)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
bFileNotFound = False
If (File.Exists(sFileName)) Then
‘ Open the input stream to read the source file.
input = New FileStream(sFileName, FileMode.Open)
If (offset <> 0) Then
input.Seek(offset, SeekOrigin.Begin)
End If
m_iBytes = input.Read(m_aBuffer, 0, m_aBuffer.Length)
Do While (m_iBytes > 0)
cSocket.Send(m_aBuffer, m_iBytes, 0)
m_iBytes = input.Read(m_aBuffer, 0, m_aBuffer.Length)
Loop
input.Close()
Else
bFileNotFound = True
End If
cSocket.Close()
End If
If (bFileNotFound) Then
MessageString = m_sReply
Throw New IOException("The file: " & sFileName & " was not found." & _
" Cannot upload the file to the FTP site.")
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Sub
‘ Delete a file from the remote FTP server.
Public Function DeleteFile(ByVal sFileName As String) As Boolean
Dim bResult As Boolean
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command to delete a file.
SendCommand("DELE " & sFileName)
If (m_iRetValue <> 250) Then
bResult = False
MessageString = m_sReply
End If
Return bResult
End Function
‘ Rename a file on the remote FTP server.
Public Function RenameFile(ByVal sOldFileName As String, _
ByVal sNewFileName As String) As Boolean
Dim bResult As Boolean
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command to rename a file.
SendCommand("RNFR " & sOldFileName)
If (m_iRetValue <> 350) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
‘It will overwrite if newFileName exists.
SendCommand("RNTO " & sNewFileName)
If (m_iRetValue <> 250) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
‘ Return the final result.
Return bResult
End Function
Public Function CreateDirectory(ByVal sDirName As String) As Boolean
Dim bResult As Boolean
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command to make a folder on the FTP server.
SendCommand("MKD " & sDirName)
If (m_iRetValue <> 257) Then
bResult = False
MessageString = m_sReply
End If
Return bResult
End Function
‘ This is a function that is used to delete a folder on the remote FTP server.
Public Function RemoveDirectory(ByVal sDirName As String) As Boolean
Dim bResult As Boolean
‘Check if you are logged on to the FTP server.
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command to remove a folder on the FTP server.
SendCommand("RMD " & sDirName)
If (m_iRetValue <> 250) Then
bResult = False
MessageString = m_sReply
End If
Return bResult
End Function
‘This is a function that is used to change the current working folder on the remote FTP server.
Public Function ChangeDirectory(ByVal sDirName As String) As Boolean
Dim bResult As Boolean
‘Check if you are in the root directory.
If (sDirName.Equals(".")) Then
Exit Function
End If
‘Check if you are logged on to the FTP server.
If (Not (m_bLoggedIn)) Then
Login()
End If
‘Send an FTP command to change the folder on the FTP server.
SendCommand("CWD " & sDirName)
If (m_iRetValue <> 250) Then
bResult = False
MessageString = m_sReply
End If
Return bResult
End Function
‘ Close the FTP connection of the remote server.
Public Sub CloseConnection()
If (Not (m_objClientSocket Is Nothing)) Then
‘Send an FTP command to end an FTP server system.
SendCommand("QUIT")
End If
End Sub
Private Sub ReadReply()
m_sMes = ""
m_sReply = ReadLine()
m_iRetValue = Int32.Parse(m_sReply.Substring(0, 3))
End Sub
Private Sub Cleanup()
If Not (m_objClientSocket Is Nothing) Then
m_objClientSocket.Close()
m_objClientSocket = Nothing
End If
End Sub
‘ Read a line from the FTP server.
Private Function ReadLine(Optional ByVal bClearMes As Boolean = False) As String
Dim seperator As Char = ControlChars.Lf
Dim mess() As String
m_sMes = ""
End If
Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, BLOCK_SIZE)
m_iBytes = m_objClientSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
m_sMes += ASCII.GetString(m_aBuffer, 0, m_iBytes)
If (m_iBytes < m_aBuffer.Length) Then
Exit Do
End If
Loop
If (m_sMes.Length > 2) Then
m_sMes = mess(mess.Length – 2)
Else
m_sMes = mess(0)
End If
Return ReadLine(True)
End If
End Function
‘ This is a function that is used to send a command to the FTP server that you are connected to.
Private Sub SendCommand(ByVal sCommand As String)
sCommand = sCommand & ControlChars.CrLf
Dim cmdbytes As Byte() = ASCII.GetBytes(sCommand)
m_objClientSocket.Send(cmdbytes, cmdbytes.Length, 0)
ReadReply()
End Sub
‘ Create a data socket.
Private Function CreateDataSocket() As Socket
Dim index1, index2, len As Int32
Dim partCount, i, port As Int32
Dim ipData, buf, ipAddress As String
Dim parts(6) As Int32
Dim ch As Char
Dim s As Socket
Dim ep As IPEndPoint
‘Send an FTP command to use a passive data connection.
SendCommand("PASV")
If (m_iRetValue <> 227) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
index2 = m_sReply.IndexOf(")")
ipData = m_sReply.Substring(index1 + 1, index2 – index1 – 1)
partCount = 0
buf = ""
ch = Char.Parse(ipData.Substring(i, 1))
If (Char.IsDigit(ch)) Then
buf += ch
ElseIf (ch <> ",") Then
MessageString = m_sReply
Throw New IOException("Malformed PASV reply: " & m_sReply)
End If
Try
parts(partCount) = Int32.Parse(buf)
partCount += 1
buf = ""
Catch ex As Exception
MessageString = m_sReply
Throw New IOException("Malformed PASV reply: " & m_sReply)
End Try
End If
Next
‘ bitshift the number by 8 bits. Therefore, in Visual Basic .NET 2002, you must
‘ multiply the number by 2 to the power of 8.
‘port = parts(4) * (2 ^ 8)
port = parts(4) << 8
port = port + parts(5)
ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port)
s.Connect(ep)
Catch ex As Exception
MessageString = m_sReply
Throw New IOException("Cannot connect to remote server")
‘If you cannot connect to the FTP
‘server that is specified, make the boolean variable false.
flag_bool = False
End Try
‘If you can connect to the FTP server that is specified, make the boolean variable true.
flag_bool = True
Return s
End Function
Update: Disturbing Event At Work
Posted by Kelly's Chronicles in Uncategorized on May 22, 2008
Using an XML file for application configuration
Posted by Kelly's Chronicles in vb.net on May 22, 2008
Letting the end user have control over critical elements of your vb.net application.
One of the most common questions I see involves developers trying to allow the end user to set program options, or control the location of critical application files. This blog is an attempt to assist with this endeavor!!
1) Create a Windows project under any name you wish, and then add an xml file by right clicking on the project name, and select "Add a new item" and in the dialog box select an XML file.
2) Type the following into your xml file using what you want for your mail server name. Any future settings you wish to add can be placed by typing another Key Name in just the same manner below the first one called "mailserver".
<?xml version="1.0" encoding="utf-8"?>
<Section Name="Settings">
<Key Name="mailserver" Value="mail.charter.net" />
</Section>
3) In the Form1 graciously created automatically for you by Visual Studio designer add a textbox, a label with its .Text property set to "SMTP Mail Server" and a button with the .Text property set to "Save".
4) Switch to code view by double clicking on the form. Add the following under the "Windows Form Designer Generated Code":
5) Under the form load event type what is in white. The black are comments to help you understand what is happening.
Private Sub ReadXmlConfig()
Create Xml Document instance
Dim xmlDoc As XmlDocument = New XmlDocument
load the file.
xmlDoc.Load(Application.StartupPath & "\settings.xml")
Create an array of key nodes of your xml file. Key nodes are the various elements of the xml file that hold your settings.
Dim keyNodeList As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("Key")
create an instance of a single keynode which we need to find the single key we are looking for
Dim keyNode As XmlNode
Now we loop through the nodes looking for the keynode holding our mail server value.
For Each keyNode In keyNodeList
‘Each keynode has attributes that together form a "collection." similar to an array. In this case we are seeking the "name" of the node as its attribute..
Dim attribs As XmlAttributeCollection = keyNode.Attributes
Like we did with the keynodes we create a an instance of a single "attribute" called "Name" in which we can look for our value.
Dim attrib As XmlAttribute = attribs("Name")
We are stating that in this loop if the mail server value is found we want to take the attribute of this keynode which is the mailserver value entered earlier and assign it to the string called "mailserver". Each keynode has attributes that together form a "collection." In this case we are seeking the "name" of the node as its ‘attribute..
If attrib.Value = "mailserver" Then
mailserversetting = attribs("Value").Value.ToString()
End If
Next
End Sub
6) In the form load event type
ReadXmlConfig
TextBox1.Text = mailserver
7) Build and run your project. You should see your mail server setting you assigned appear in the textbox on form load. After admiring your work, shut down the program.
8) Now we will change the value of this key as if the end user wanted to change the name of their mail server. Under the ReadXmlConfig sub place another type the following:
Sub EnterUserSettings()
Dim strOldEmailValue As String
Try
Create Xml Document instance
Dim xmlDoc As XmlDocument = New XmlDocument
load the file.
xmlDoc.Load(Application.StartupPath & "\settings.xml")
Create an array of key nodes of your xml file. Key nodes are the various elements of the xml file that hold your settings.
Dim keyNodeList As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("Key")
create an instance of a single keynode which we need to find the single key we are looking for
Dim keyNode As XmlNode
Now we loop through the nodes looking for the keynode holding our mail server value.
For Each keyNode In keyNodeList
Each keynode has attributes that together form a "collection." similar to an array. In this case we are seeking the "name" of the node as its attribute..
Dim attribs As XmlAttributeCollection = keyNode.Attributes
Like we did with the keynodes we create a an instance of a single "attribute" called "Name" in which we can look for our value.
Dim attrib As XmlAttribute = attribs("Name")
We are stating that in this loop if the mail server value is found we want to take the attribute of this keynode which is the mailserver value entered earlier and assign it to the string called "mailserver". Each keynode has attributes that together form a "collection." In this case we are seeking the "name" of the node as its ‘attribute..
If attrib.Value = mailserver Then
assigning the old value to a variable – in case the settings change fails
strOldValue = attribs("Value").Value.ToString()
set the new value of this key now
attribs("Value").Value = TextBox1.Text
End If
save the xml file
xmlDoc.Save(Application.StartupPath & "\settings.xml")
Next
letting the user know of the change
MsgBox("Your mail server is " & chooselocation, MsgBoxStyle.Information)
Exit Sub
End If
Catch As System.IO.IOException
if saving the file failed
Select Case MessageBox.Show("There was a problem Saving the file, would you like to try another location?")
Case DialogResult.Ok
Dim od as New OpenFileDialog
od.ShowDialog
Dim FileLocation as String = od.FullName
xmlDoc.Save("Blah Blah Blah)
Case DialogResult.No
MessageBox.Show(ex.Message, "File Not Saved")
‘ or whatever routine you want.
End Select
MsgBox("SETTING " & mailserversetting.ToUpper & " FAILED" & vbCrLf & ex.ToString)
End Try
9) In the designer double click on the button1 and add the sub "EnterUserSettings". Compile and run your project and change the value of the email server in TextBox1.
That’s all folks!! That wasn’t so bad was it? Please be sure to leave comments if it helped you and where you were referred. Thanks.
End Of An Era – Or is it?
Posted by Kelly's Chronicles in Music on May 21, 2008
Little did I know when this band started how much it would change my life and of those around me. We started out with musicians who for the most part had never had any experience in music other than what a worship and praise band would do. Doing that is good, but rock music was a whole other world believe me! Not to mention I was ill suited to be the leader of a Christian band. I am not an overly social person, lacked patience with people, am slow to trust, didnt like to add relatoinships, and my organazational skills left a lot to be desired. I had no knowledge of how to run a sound board. I liked to write music and was fairly competent with words but translating that to something outside of my basement had never been tried before. I had experience with rock and roll bands but still this was again a huge departure from that world.
So I becamse forced to be social, to be organized, to be tolerant, and to adjust my thinking in virtually every way. My wife used to sit their in amazement when she would see me on the phone talking to people because it was something I would rarely do and if so would be virtually forced. I would gather the group to talk to them and I am sure she wondered where her husband had gone because I never would speak up about anything.
My band mates we will start with Jean.
Jean – Jean initially was skeptical Jericho would succeed particuarly in a Lutheran Church – Missouri Synod congregation. But she came on board with it soon enough. Running a band is hard enough but when a member also happens to be your wife it contains it own set of challenges as the band will attest to! But at the end of the day Jean and I were better for it. She also had sang in Christian band previosly as had I called Crossroads from Bethany Reformed Church in Sheboygan WI. She had developed a very powerful voice over the years and could harmonzie on the fly better than anyone I have known.
Kim was a vocalist who I had heard who had a beautiful rich voice but was in my opinion never really given the opportunity to spread her wings so to speak and flourish. WHen I approached her to sing with us, she was enthusiastic but scared. She had never done rock and roll but the opportunity to team up with Jean (these two were good friends by this point not to mention when they sing together it is just electric) it proved irresistable to her.
Dean was a bass player who when approached was eager to get on board. When I first met Dean, he wore what I somewhat affectionalty refer to as a "Burger King mic and was extremely soft in his singing voice. He played what i call "straight bass" – standard in worship bands.
Dan was a drummer who had never really done anything but the standard 8 beat rhythem required of worship band drummers for years. Again he was eager to get involved.
Zach, Dan’s son would end up being our guitar player. But when Jericho first started he had barely begun to learn the guitar. IN fact at first we would often unplug him from the system because the racket coming from his guitar was amazing. But again he was willing and enthusiastic.
By all rights, with a leader who shouldnt lead, a guitar player who couldnt play, a bass player who wouldnt sing, a voclaist who was timid, a drummer who had long ago put the rock and roll sticks away, and having the conflict between my wife and i in the band there is no way this band should have succeeded. Not in a million years.
But I guess it goes to show that what we think impossible God will make it work!
Today as it stands
Kim – She found her voice! She can do the blues! Who would have thought it! That flower really bloomed!
Dean – He plays "The House is Rocking" (we changed to "God’s House Is Rocking") on bass. Does that tell you anything? And vocally he sand LEAD on several songs and we actually have to turn him down sometimes now! And he became an expert on soundboards which was very lucky for us!
Dan – I am very happy at how he came along. He could do the swing required on Eagles songs and every task we called on him to do he was able to do and do well. He truly became a rock and roll drummer again.
Zach – Are you kidding me? Today he plays guitars in several bands, plays trumpet, piano and is going to be a music major somewhere.
Jean – Jean does rock and roll sports fans!! She always said she didnt want to do it but then she did it extremely well. And I think deep down she really liked it too… 🙂
As for me, well I became social. I was organized (most of the time). I was patient. I formed relationships. Who would have thunk it????
So with all that, with us moving, we have one more gig at Bethany Reformed Church at the end of May. Ironically where our first gig was. So what will become of Jericho? No one really knows. We talk of joining up occasionally but you all know how that goes after you move. We all say we will stay in touch but it rarely happens. I hope it does this time. The website will go down and we wont have regaularly scheduled gigs. But regardless of what happens we all grew – both in faith and talent. And I would say we are all better off for the experience.
Today I met with the pastor of my new church here in Hartland WI (http://oakwoodnow.org/) and discussed with him the ideas of doing what I did in Sheboygan here. And so the process begins again……..stay tuned!
KJM Solutions Web Site Going Down
Posted by Kelly's Chronicles in Computers and Internet on May 21, 2008
Recent Comments