gr8life
asked on
Performance Improvements
I am currently using the code below in an application which I am trying to enhance performance. I am looking for suggestions for improving performance of this code. The database being used has one table named Country, with three columns named LIP1, LIP2, and countryname.
Public Function IPLookup(ByVal DottedIP As String) As String
Dim lngIP As Long
Dim strCountry As String
Dim con As New OleDbConnection
Dim dtm As DataTableMapping
Dim da As New OleDbDataAdapter
Dim cmdSelect As New OleDbCommand
Dim ds As New DataSet
Dim dt As DataTable
lngIP = Dot2LongIP(DottedIP)
con.ConnectionString = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source = C:\resource\master.mdb"
dtm = da.TableMappings.Add("Tabl e", "Country")
cmdSelect.CommandText = "SELECT countryname FROM Country WHERE " & lngIP.ToString & " >= ipl1 and " _
& lngIP.ToString & " <= ipl2"
cmdSelect.Connection = con
da.SelectCommand = cmdSelect
da.Fill(ds)
dt = ds.Tables("Country")
If dt.Rows.Count = 0 Then
strCountry = "Unknown"
Else
strCountry = dt.Rows(0).Item("countryna me")
End If
Return strCountry
End Function
End Class
Thank you very time and expertise,
Gr8life
Public Function IPLookup(ByVal DottedIP As String) As String
Dim lngIP As Long
Dim strCountry As String
Dim con As New OleDbConnection
Dim dtm As DataTableMapping
Dim da As New OleDbDataAdapter
Dim cmdSelect As New OleDbCommand
Dim ds As New DataSet
Dim dt As DataTable
lngIP = Dot2LongIP(DottedIP)
con.ConnectionString = "Provider=Microsoft.Jet.OL
dtm = da.TableMappings.Add("Tabl
cmdSelect.CommandText = "SELECT countryname FROM Country WHERE " & lngIP.ToString & " >= ipl1 and " _
& lngIP.ToString & " <= ipl2"
cmdSelect.Connection = con
da.SelectCommand = cmdSelect
da.Fill(ds)
dt = ds.Tables("Country")
If dt.Rows.Count = 0 Then
strCountry = "Unknown"
Else
strCountry = dt.Rows(0).Item("countryna
End If
Return strCountry
End Function
End Class
Thank you very time and expertise,
Gr8life
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for all your help!
Gr8life
Gr8life
ASKER
Thank you for the great advice,
Gr8life