I'll show you my code first (at least all i think you need) and then explain the problem.
Expand|Select|Wrap|Line Numbers
- Function GetTimeZone(ByVal state As String) As Integer
- Dim TaxConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ConfigurationManager.AppSettings("Database")
- Dim dbConnection As OleDbConnection = New OleDbConnection(TaxConnStr)
- Try
- Dim queryString As String
- queryString = "SELECT Top 1 Zips.State, Zips.TimeZone "
- queryString += "FROM Zips "
- queryString += "WHERE (((Zips.State)='" & state & "'));"
- Dim dbCommand As OleDbCommand = New OleDbCommand
- dbCommand.CommandText = queryString
- dbCommand.Connection = dbConnection
- Dim dataAdapter As OleDbDataAdapter = New OleDbDataAdapter
- dataAdapter.SelectCommand = dbCommand
- Dim dataSet As DataSet = New DataSet
- dataAdapter.Fill(dataSet)
- If dataSet.Tables(0).Rows.Count >= 1 Then
- Return dataSet.Tables(0).Rows(0).Item("TimeZone")
- Else
- Return 0
- End If
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- myLogger.Log(ex.Message)
- Finally
- dbConnection.Close()
- End Try
- End Function
So i would ultimately like this function to look at the zip code...find out which time zone that zip code is in...and then return the time zone.
If it's not apparent. The table this information is pulling from is named "Zips". It consists of several columns ranging from zip, city, state, county, areacode, and timezone. The timezone is column in the table only has values such as "5,6,7,8,etc" to correspond to each timezone. 5 = Eastern, 6 = Central, so on..
Thanks for any guidance.