Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
joopdog
Starting Member
4 Posts |
Posted - 2006-02-15 : 13:30:16
|
I want to create an SQL statemant in VB.NET.Dim Sql As StringDim Cmd As OleDbCommandDim Reader As OleDbDataReaderDim Con = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" & _ "data source=D:\!install\My Files\email\Country IPs\IPtoCountry_01.mdb") Sql = "SELECT * FROM [IPAddressList] WHERE [StartIPNo]>=" & IP_Address & "And [EndIPNo]<=" & IP_AddressCmd = New OleDbCommand(Sql, Con)Con.Open()Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)If Reader.Read() Then Label3.Text = "Data Found "Else Label3.Text = "Nothing Found."End IfCon.Close()It doesn’t work. It passes through the debugging, searches through the access database, but it pulls no data.StartIP________|EndIP__________|StartIPNo_|EndIPNo__|CountryCode005.000.000.000 |005.163.066.079 |83886080 |94585423 |ZA005.163.066.080 |005.163.066.095 |94585424 |94585439 |SE005.163.066.096 |005.255.255.255 |94585440 |100663295 |ZAIf the user types in the IP_Address, such as "83886080", I want it to check the values between the StartIPNo and EndIPNo and return the CountryCode. In this case, it should return "ZA".Any help would be appreciated |
|
joopdog
Starting Member
4 Posts |
Posted - 2006-02-15 : 14:01:54
|
I figured it out. I had the greater and less than signs pointed the wrong way.Sql = "SELECT * FROM [IPAddressList] WHERE [StartIPNo]<=" & IP_Address & "And [EndIPNo]>=" & IP_AddressThanks |
 |
|
|
|
|