Click to See Complete Forum and Search --> : [RESOLVED] Fill the data row items on listview


mark103
July 16th, 2008, 10:50 AM
Hi

I need help, I would like to fill the data row items on my listview when I connect to the right server name like germany and fill the right items that connected to the right germany server.




Here it the code:

Private Sub FindServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindServer.Click

If GetHTMLPage("http://www.whatismyip.com" & ProxyAddress.Text, chkUseProxy.Checked, ProxyAddress.Text, IIf(IsNumeric(ProxyPort.Text), ProxyPort.Text, 0), UserName.Text, Password.Text) Is "" Then
TextBox1.Text = TextBox1.Text
Else
TextBox1.Text = ProxyAddress.Text
End If
End Sub


Public Function GetExternalIP() As String
Dim IP_URL As String = "http://checkip.dyndns.org"
Dim strHTML, strIP As String
Try
Dim objWebReq As System.Net.WebRequest = System.Net.WebRequest.Create(IP_URL)
Dim objWebResp As System.Net.WebResponse = objWebReq.GetResponse()
Dim strmResp As System.IO.Stream = objWebResp.GetResponseStream()
Dim srResp As System.IO.StreamReader = New System.IO.StreamReader(strmResp, System.Text.Encoding.UTF8)
strHTML = srResp.ReadToEnd()
Dim regexIP As System.Text.RegularExpressions.Regex
regexIP = New System.Text.RegularExpressions.Regex("\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b")
strIP = regexIP.Match(strHTML).Value
Return strIP
Catch ex As Exception
MessageBox.Show("Can't retrieve external IP: " & ex.Message)
Return Nothing
End Try
End Function

Public Function GetHTMLPage(ByVal URL As String, Optional ByVal UseProxy As Boolean = False, Optional ByVal ProxyAddress As String = "", Optional ByVal ProxyPort As Integer = 0, Optional ByVal UserName As String = "", Optional ByVal PassWord As String = "", Optional ByVal Domain As String = "") As String


Dim sResult As String = ""
Try
Dim objResponse As WebResponse
Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(URL)

If UseProxy Then
Dim oProxy As New WebProxy(ProxyAddress, ProxyPort)
If Domain <> "" Then
oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain)
Else
oProxy.Credentials = New NetworkCredential(UserName, PassWord)
End If
objRequest.Proxy = oProxy
End If


objRequest.Method = "GET"
objRequest.Timeout = 120000 ' 20 sec.
objResponse = objRequest.GetResponse

Dim sr As System.IO.StreamReader = New System.IO.StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7)

sResult = sr.ReadToEnd()
sr.Close()
' when code-execution has reached this point without
' throwing an error, the html page is loaded which
' means all is o.k.
MessageBox.Show("You are connected success")
Catch ex As System.Exception
Debug.WriteLine(ex.Message)
MessageBox.Show("You have failed connected")
End Try
Return sResult
End Function

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

TextBox1.Text = GetExternalIP()

If chkUseProxy.Checked = False Then
ProxyAddress.Enabled = True
ProxyPort.Enabled = True
ElseIf chkUseProxy.Checked = True Then
ProxyAddress.Enabled = False
ProxyPort.Enabled = False
End If
End Sub

Private Sub chkUseProxy_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkUseProxy.CheckedChanged
If chkUseProxy.Checked = False Then
ProxyPort.Enabled = True
ProxyAddress.Enabled = True
ElseIf chkUseProxy.Checked = True Then
ProxyPort.Enabled = False
ProxyAddress.Enabled = False
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' 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



When I click the button that connecting to the database, the program filled the data row items without connected to the server like germany. I need the items to be separate and some items to be filled only when I connected to the server like germany???



Hope you can help!




Thanks,
Mark

mark103
July 16th, 2008, 07:37 PM
do anyone know what site I could find the information of three first code in each country servers to detect it in a proper way??



Something would be like this:


141.13.16.201:3128
141.24.33.162:3127
141.24.33.162:3124
137.226.138.154:3128
138.246.99.249:3127
141.13.16.201:3124
137.226.138.154:3127
137.226.138.154:3124
139.19.142.2:3128
134.34.246.5:3124
139.19.142.4:3127
139.19.142.1:3127
139.19.142.4:3128
139.19.142.6:3124
139.19.142.4:3124
139.19.142.1:3124
139.19.142.3:3127
139.19.142.5:3124
139.19.142.6:3128
134.002.172.252:3127
139.19.142.1:3128
139.19.142.6:3127
131.246.191.42:3127




You can see the first three code something like this 131. I need to find the site information of detect server, for e.g: Germany server the first three code would be from 131 to 141. It could be randoms numbers of the server code so I would to find situations to detect the server in a proper way instead than writing hundred thousands lines of the code.



Please can someone help me!!!!!!!!!!!!!




Thanks,
Mark

mark103
July 17th, 2008, 10:47 AM
anyone???????????????????????

dglienna
July 17th, 2008, 05:03 PM
1) You're loading CARS from C:\db1_test.mdb, not online anywhere.

2) You have code for gethtml, but don't call it.

3) Read the info from the site that checked the ip for a location.

mark103
July 17th, 2008, 06:50 PM
I WOULD PUT ONLINE IF I GET THIS DONE FIRST!!!!!!!!



You said I have code for gethtml but don't call it. I need it because I need to access to the proxy server but I don't know how I could checked the ip for a location with proxy on gethtml statement??

1) You're loading CARS from C:\db1_test.mdb, not online anywhere.

2) You have code for gethtml, but don't call it.

3) Read the info from the site that checked the ip for a location.

dglienna
July 17th, 2008, 08:52 PM
Are you trying to create a server (that people can access from different locations in the world), or do you want to create a client?

If you makee a client, you know where you are.

If you use a proxy, you appear to be from wherever the proxy address is

Please explain...

mark103
July 18th, 2008, 09:48 AM
No, I am trying to make a client by connecting to the proxy server and scan ip country mapping then displaying correct data information from my own database. I got IP-country mapping database but I cant find the source code to scan ip-country mapping for proxy and input the correct ip-country information from my own database??





Hope you can help!!!!!!


Thanks,
Mark

HairyMonkeyMan
July 18th, 2008, 09:51 AM
Do you have the ip country mappings in your database and the user's external ip address?

Is it the database query you need help with?

mark103
July 18th, 2008, 10:00 AM
Yes I do, I have ip country mappings database but I did not put them in my own database. I don't think I have put my external ip address in the database??





I have dynamic ip address which it is impossible to retrieve ip-country from the database. And I need source code to scan ip-country mapping, I need to get them working with the external ip address and proxy server.



Thanks,
Mark

dglienna
July 18th, 2008, 06:01 PM
It's always going to be the address of the proxy that you are using, so is that what you want to select? The proxy address from the country code table?

Why don't you post the table that you have? That might be useful to others.

dglienna
July 18th, 2008, 06:49 PM
What do you expect me to do? I won't write the code for you, if that's what you expect. I'll look at it later anyways, but I don't expect a lot, other than code copied from somewhere that you don't even understand.

If that's the case, it means you didn't get any books, and still want others to do your work for you.

mark103
July 18th, 2008, 07:11 PM
I would like you to check and fix the code. I want to scan the country code on IPCountry database and read my database then fill the data from my database when the server retrieve as country code from IPCountry database.




It should do with Private Sub Button1_Click and Public Function GetCountyFromIP statement, it might work together but I am not sure which one is the proper way of doing in the right way....




Hope you can help!!!!!!!!!!




Thanks,
Mark