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.

 All Forums
 Other Forums
 MS Access
 How do I create an SQL statement?

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 String
Dim Cmd As OleDbCommand
Dim Reader As OleDbDataReader
Dim 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_Address
Cmd = 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 If
Con.Close()

It doesn’t work. It passes through the debugging, searches through the access database, but it pulls no data.


StartIP________|EndIP__________|StartIPNo_|EndIPNo__|CountryCode
005.000.000.000 |005.163.066.079 |83886080 |94585423 |ZA
005.163.066.080 |005.163.066.095 |94585424 |94585439 |SE
005.163.066.096 |005.255.255.255 |94585440 |100663295 |ZA

If 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_Address

Thanks
Go to Top of Page
   

- Advertisement -