Question Question how to seperate or ignore the data

mark103

New member
Local time
Yesterday, 16:38
Joined
Jul 22, 2008
Messages
4
Hi

I need help with my database. I have problem, when I input the ip address on the textbox and when I click the button, I get access to the ip country database to read the information of end num and country code to retrieve the ip as country and the program get access to my own database then they filled the wrong data that have not matched the country code or not have been separate with other data by did not ignore it. I have stored the data on the same column with other data while the country code is on the next column.




Here it is the code:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dblIP As Double
        dblIP = Dot2LongIP(TextBox1.Text)

        Dim con As New OleDb.OleDbConnection()
        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =IPCountry.mdb "
        Dim strCountry As String
        Dim olecommand As New OleDb.OleDbCommand("SELECT  country FROM ip2country  WHERE " & dblIP & " BETWEEN begin_num AND end_num ;", con)
        olecommand.Connection.Open()
        strCountry = olecommand.ExecuteScalar()
        

        If Not strCountry Is Nothing Then
            strCountry = CountryName(strCountry)
            Return
        End If
        Try

        Catch exc As Exception
            Throw exc
        End Try

        
' Connect to the database and retreive the data required from Table1 into a datatable object.
        Dim da As New System.Data.OleDb.OleDbDataAdapter( _
            "SELECT Car, Images FROM Table1 ORDER BY Car DESC", _
            "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1_test.mdb;Persist Security Info=False;")
        Dim dt As New DataTable
        da.Fill(dt)

        ' Place a new imagelist control onto your form designer window. The following
        ' will assign the listview to read from this control.
        With ListView1
            .LargeImageList = ImageList1
            .SmallImageList = ImageList1
        End With

        Dim img As Image
        Dim intImageIndex As Integer = 0

        ' Loop through each row in the database.
        For Each row As DataRow In dt.Rows
            ' First off, check we have a record value within the Car column.
            If Not String.IsNullOrEmpty(row.Item("Car")) Then

                ' If there is an image contained within the row, retreive this into a new image object.
                ' Next, add this image into the imagelist control & output the car name and image to the
                ' listview as a newlist item. This last call references the image by index number, which
                ' is kept track of in the intImageIndex variable - incremented upon each loop iteration.
                If Not (row.Item("Images") Is Nothing) Then
                    img = Image.FromStream(New IO.MemoryStream(DirectCast(row.Item("Images"), Byte())))
                    ImageList1.Images.Add(row.Item("Car").ToString, img)
                    ListView1.Items.Add(row.Item("Car").ToString, intImageIndex)
                Else
                    ' If we arrived at this point, we have a car record entry, but no image. Therefore
                    ' we will just output the info we do have into a new listview listitem.
                    ListView1.Items.Add(row.Item("Car").ToString)
                End If
            Else
                ' If we arrived here at this point in the code, then no record beneath the Car column
                ' exists for the row. Here we check if there's an image record and output that if
                ' existing in the same manner as above.
                If Not (row.Item("Images") Is Nothing) Then
                    img = Image.FromStream(New IO.MemoryStream(DirectCast(row.Item("Images"), Byte())))
                    ImageList1.Images.Add("{NULL Value}", img)
                    ListView1.Items.Add("{NULL Value}", intImageIndex)
                End If
            End If

            intImageIndex += 1
        Next

        If ListView1.Items.Count = 2 Then
            Me.ListView1.Items.Clear()
        End If
    End Sub



What I am trying to do: I want to read the end num and the country code columns information from the ip country database while the ip text is on the textbox and I want to find out where the ip is coming from so when I retrieve the ip as country, i want to read my own database while read the country code to find out which data I want to fills on my listview then filled the correct data that have matched the country code but ignore the other data that have not matched the country code.





How can I ignore and separate with the other data when I match the country code??




Hope you can help!



Thanks,
Mark
 
Hi Mark, your question sounds fascinating but I think there may be a language problem. For the life of me, I couldn't figure out what you were talking about.

Maybe if you re-state the problem in a different way somebody could figure out what you need and reply?
 
thanks for your reply, can you see my sentence above??



This is what I am trying to say again and again....


What I am trying to do: I want to read the end num and the country code columns information from the ip country database while the ip text is on the textbox. Then I want to find out where the ip is coming from and when I retrieve the ip as country, i want to get access to my database while read the country code to find out which data I want to fills on my listview then filled the correct data that have matched the country code.



Hope this is clear to you that you may understand this now??



If not, please can you let me know which part of the sense you may not understand with. And I will tell you what I need.




Thanks,
Mark



Hi Mark, your question sounds fascinating but I think there may be a language problem. For the life of me, I couldn't figure out what you were talking about.

Maybe if you re-state the problem in a different way somebody could figure out what you need and reply?
 

Users who are viewing this thread

Back
Top Bottom