candlestick
New member
- Joined
- Apr 6, 2009
- Messages
- 3
- Programming Experience
- Beginner
Hi Guys,
A. Not sure if this is the correct place to post
B. Bit of a noob with the old VB.net.
Just wrote a function in my service that is meant to return a dictionary of string string but no joy. Im not sure if my syntax is correct at all. Can someone have a quick look and let me know please?
Here is the source:
A. Not sure if this is the correct place to post
B. Bit of a noob with the old VB.net.
Just wrote a function in my service that is meant to return a dictionary of string string but no joy. Im not sure if my syntax is correct at all. Can someone have a quick look and let me know please?
Here is the source:
VB.NET:
'===== call the function ========
Dim External_line_prefixes As Dictionary(Of String, String) = GetAllExternalLinePrefixes()
'===== the function ========
Private Function GetAllExternalLinePrefixes()
'pre: oncall retrives all records from the linePrefix and region columns of the site lookup table
'post: returns a dictionary collection of the site names and the prefixes
'NT: Dictionary format = site_line_prefixes[<str_sitename>][<str_prefix>]
'NT: Set the table name in the .config file under appsettings with keyname: siteTableName.
'==connect to db==
Dim objconn As Object
objconn = DatabaseConnection()
Dim objCommand As SqlClient.SqlCommand
objconn.Open()
'==get site table variables for sql command from .config file==
Dim strTableName As String = System.Configuration.ConfigurationManager.AppSettings.Item("SiteTableName").ToString()
'==create and run querie for extracting all line prefixes and the site names==
Dim returnValue As SqlClient.SqlDataReader
objCommand = New SqlClient.SqlCommand("select lineprefix, region, didgitstouse from " & strTableName)
returnValue = objCommand.ExecuteReader()
'==read querie results into dictionary collection object==
'create a string dictionary object
Dim site_line_prefixes As New Dictionary(Of String, String)
'loop through all results
While returnValue.Read()
'add sitename as dictionary key and prefix as dictionary value
site_line_prefixes.Add(returnValue(0), returnValue(1) & "^" & returnValue(2))
End While
'==close and return==
'close objects
objconn.Close()
objconn.Dispose()
objCommand.Dispose()
objconn = Nothing
objCommand = Nothing
'return dictionary
Return site_line_prefixes
End Function
Last edited by a moderator: