muralimohan_j
New member
- Joined
- Dec 19, 2003
- Messages
- 4
Here is the VB.Net Code which throws the error.....pls. do let me if you find something wrong in the below code....
Imports System.Windows.Forms.Application
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form
Option Explicit
Dim cn As New ADODB.Connection
Dim hbr As New mshtml.HTMLBRElement
Dim rec As New ADODB.Recordset
Dim var1 As String
Dim bl As Boolean
Dim x As Long
Dim bdata() As Byte
Dim localpath, source1 As String
Dim inetIMAGE As New Inet
Dim temp, temp1, chk, map, near, var3, var4, imgavbl As String
Dim res As Integer
Dim source As String
Dim strurl As String
Dim k, i, z, j, l, ctr, ctr1 As Integer
Dim objMSHTML As New mshtml.HTMLDocument
Dim objANC As New mshtml.HTMLAnchorElement
Dim objDoc As New mshtml.HTMLDocument
Dim objLINK As New mshtml.HTMLLinkElement
Dim objTEXT As New mshtml.HTMLTextElement
Dim objIMAGE As New mshtml.HTMLImg
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=;Initial Catalog=db;Data Source=dbserver"
cn.Open()
rec.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rec.Open("SELECT * from table", cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Open "c:\dcartgallerieslog.txt" For Output As #2
MsgBox(rec.RecordCount)
While Not rec.EOF
strurl = "http://www.blahblah.com/" & rec("city").Value & "/ent/ven.asp?vid=" & rec("vid").Value
objDoc = objMSHTML.createDocumentFromUrl(strurl, vbNullString)
While objDoc.readyState <> "complete"
DoEvents()
End While
If TextBox1.Text = "Visitors Guide" Then
objTEXT = objDoc.getElementsByTagName("table").item(14)
TextBox1.Text = objTEXT.innerText
If InStr(TextBox1.Text, "The page that you are looking for either does not exist,") > 0 Then
Else
objTEXT = objDoc.getElementsByTagName("table").item(9)
TextBox1.Text = objTEXT.innerText
If InStr(TextBox1.Text, "Plan Your Weekend") > 0 Then
Else
temp = Replace(TextBox1.Text, "", "")
If InStr(temp, Chr(10)) > 0 Then
temp = Trim(Mid(temp, 1, InStr(temp, Chr(10))))
temp = Trim(Replace(temp, Chr(10), ""))
End If
If InStr(temp, Chr(13)) > 0 Then
temp = Trim(Mid(temp, 1, InStr(temp, Chr(13))))
temp = Trim(Replace(temp, Chr(13), ""))
End If
objTEXT = objDoc.getElementsByTagName("table").item(14)
TextBox1.Text = objTEXT.innerText
temp1 = Replace(TextBox1.Text, "", "")
If InStr(temp1, "More Info About") > 1 Then
temp1 = Trim(Mid(temp1, 2, InStr(temp1, "More Info About") - 2))
Else
End If
temp1 = Replace(temp1, Chr(10), Chr(13))
chk = "Y"
Do While chk = "Y"
temp1 = Trim(Replace(temp1, Chr(13) & Chr(13), Chr(13)))
If InStr(temp1, Chr(13) & Chr(13)) > 0 Then
chk = "Y"
Else
chk = "N"
End If
Loop
imgavbl = "N"
map = "N"
near = "N"
For i = 1 To objDoc.getElementsByTagName("img").length - 1
objIMAGE = objDoc.getElementsByTagName("img").item(i)
source = objIMAGE.src
If source = "http://www.blahblahblah.com/apq/ap_ic" Then
map = "Y"
End If
If source = "http://www.blahblahblah.com/apq/wts_arb" Then
near = "Y"
End If
If source = "http://www.blahblahblah.com/ertnt_nus_ew/" & rec("vid").Value Then
imgavbl = "Y"
End If
Next
objDoc = Nothing
strurl = "http://www.blahblah.com/" & rec("city").Value & "/siorue/eue.asp?vid=" & rec("vid").Value & "&type=details"
objDoc = objMSHTML.createDocumentFromUrl(strurl, vbNullString)
While objDoc.readyState <> "complete"
DoEvents()
End While
For z = 1 To objDoc.getElementsByTagName("a").length - 1
objANC = objDoc.getElementsByTagName("a").item(z)
var3 = LCase(objANC.href)
If InStr(var3, "http://www.blahblahblah.com/edr.dsi?url=") > 0 Then
If InStr(var3, "classifieds") > 0 Or InStr(var3, "atwola") > 0 Then
Else
var3 = Replace(var3, "%3a", ":")
var3 = Replace(var3, "%20", " ")
var3 = Replace(var3, "%2f", "/")
var3 = Replace(var3, "%2e", ".")
var3 = Replace(var3, "%2d", "-")
var3 = Replace(var3, "%3f", "?")
var3 = Replace(var3, "%3d", "=")
var3 = Replace(var3, "%5f", "_")
var3 = Replace(var3, "%26", "&")
var3 = Replace(var3, "%23", "#")
var3 = Replace(var3, "%7e", "~")
var3 = Replace(var3, "%2b", "+")
var3 = Replace(var3, "%25", "%")
var3 = Replace(var3, "%3a", ":")
var4 = Mid(var3, InStr(var3, "url=") + 4, InStr(var3, "&_dci_setc") - (InStr(var3, "url=") + 4))
End If
End If
If InStr(var3, "nunry.asp?") > 0 Then
near = Mid(var3, InStr(var3, "nunry.asp?"))
End If
Next
ctr1 = 0
For i = 128 To 255
k = InStrRev(temp1, Chr(i))
ctr = 0
l = 1
For j = 1 To k
If InStr(l, temp1, Chr(i)) > 0 Then
l = l + InStr(l, temp1, Chr(i))
ctr = ctr + 1
End If
Next
If ctr > 0 Then
Print(2, rec("vid").Value & Chr(9) & i & Chr(9) & Chr(i) & Chr(9) & ctr)
ctr1 = ctr1 + ctr
End If
Next
If ctr1 > 0 Then
Write(2, "No. of Spl Characters : " & Chr(9) & ctr1)
End If
Print(2, temp1)
Print(2)
Print(2, "**********************************************************************************************************************************")
*****Portion to Grab Images******
If imgavbl = "Y" Then
source = "http://www.blahblahblah.com/emnt_eus_ew/" & rec("vid").Value
localpath = "c:\dcartgalleriesimg\" & rec("vid").Value & ".jpg"
Open localpath For Binary As #1
For z = 0 To UBound(bdata)
Put #1, , bdata(z)
Next
Close #1
End If
bdata = inetIMAGE.OpenURL(source, icByteArray)
Open localpath For Binary As #1
For z = 0 To UBound(bdata)
Put #1, , bdata(z)
Next
Close #1
cn.Execute ("update table set imagestatus = " & imgavbl & " where vid = " & rec("vid") & "")
cn.Execute("update table set desc1 = " & temp1 & ",title = " & temp & ",officialurl = " & var4 & ",imagestatus = " & imgavbl & ", maplink = " & map & ",nearbylink = " & near & " where vid = " & rec("vid").Value & "")
source = ""
objDoc = Nothing
objTEXT = Nothing
temp1 = ""
temp = ""
map = ""
near = ""
imgavbl = ""
var4 = ""
Erase bdata()
End If
End If
rec.MoveNext()
End While
Close #2
MsgBox("Done")
End
End Sub
End Class
Imports System.Windows.Forms.Application
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form
Option Explicit
Dim cn As New ADODB.Connection
Dim hbr As New mshtml.HTMLBRElement
Dim rec As New ADODB.Recordset
Dim var1 As String
Dim bl As Boolean
Dim x As Long
Dim bdata() As Byte
Dim localpath, source1 As String
Dim inetIMAGE As New Inet
Dim temp, temp1, chk, map, near, var3, var4, imgavbl As String
Dim res As Integer
Dim source As String
Dim strurl As String
Dim k, i, z, j, l, ctr, ctr1 As Integer
Dim objMSHTML As New mshtml.HTMLDocument
Dim objANC As New mshtml.HTMLAnchorElement
Dim objDoc As New mshtml.HTMLDocument
Dim objLINK As New mshtml.HTMLLinkElement
Dim objTEXT As New mshtml.HTMLTextElement
Dim objIMAGE As New mshtml.HTMLImg
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=;Initial Catalog=db;Data Source=dbserver"
cn.Open()
rec.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rec.Open("SELECT * from table", cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Open "c:\dcartgallerieslog.txt" For Output As #2
MsgBox(rec.RecordCount)
While Not rec.EOF
strurl = "http://www.blahblah.com/" & rec("city").Value & "/ent/ven.asp?vid=" & rec("vid").Value
objDoc = objMSHTML.createDocumentFromUrl(strurl, vbNullString)
While objDoc.readyState <> "complete"
DoEvents()
End While
If TextBox1.Text = "Visitors Guide" Then
objTEXT = objDoc.getElementsByTagName("table").item(14)
TextBox1.Text = objTEXT.innerText
If InStr(TextBox1.Text, "The page that you are looking for either does not exist,") > 0 Then
Else
objTEXT = objDoc.getElementsByTagName("table").item(9)
TextBox1.Text = objTEXT.innerText
If InStr(TextBox1.Text, "Plan Your Weekend") > 0 Then
Else
temp = Replace(TextBox1.Text, "", "")
If InStr(temp, Chr(10)) > 0 Then
temp = Trim(Mid(temp, 1, InStr(temp, Chr(10))))
temp = Trim(Replace(temp, Chr(10), ""))
End If
If InStr(temp, Chr(13)) > 0 Then
temp = Trim(Mid(temp, 1, InStr(temp, Chr(13))))
temp = Trim(Replace(temp, Chr(13), ""))
End If
objTEXT = objDoc.getElementsByTagName("table").item(14)
TextBox1.Text = objTEXT.innerText
temp1 = Replace(TextBox1.Text, "", "")
If InStr(temp1, "More Info About") > 1 Then
temp1 = Trim(Mid(temp1, 2, InStr(temp1, "More Info About") - 2))
Else
End If
temp1 = Replace(temp1, Chr(10), Chr(13))
chk = "Y"
Do While chk = "Y"
temp1 = Trim(Replace(temp1, Chr(13) & Chr(13), Chr(13)))
If InStr(temp1, Chr(13) & Chr(13)) > 0 Then
chk = "Y"
Else
chk = "N"
End If
Loop
imgavbl = "N"
map = "N"
near = "N"
For i = 1 To objDoc.getElementsByTagName("img").length - 1
objIMAGE = objDoc.getElementsByTagName("img").item(i)
source = objIMAGE.src
If source = "http://www.blahblahblah.com/apq/ap_ic" Then
map = "Y"
End If
If source = "http://www.blahblahblah.com/apq/wts_arb" Then
near = "Y"
End If
If source = "http://www.blahblahblah.com/ertnt_nus_ew/" & rec("vid").Value Then
imgavbl = "Y"
End If
Next
objDoc = Nothing
strurl = "http://www.blahblah.com/" & rec("city").Value & "/siorue/eue.asp?vid=" & rec("vid").Value & "&type=details"
objDoc = objMSHTML.createDocumentFromUrl(strurl, vbNullString)
While objDoc.readyState <> "complete"
DoEvents()
End While
For z = 1 To objDoc.getElementsByTagName("a").length - 1
objANC = objDoc.getElementsByTagName("a").item(z)
var3 = LCase(objANC.href)
If InStr(var3, "http://www.blahblahblah.com/edr.dsi?url=") > 0 Then
If InStr(var3, "classifieds") > 0 Or InStr(var3, "atwola") > 0 Then
Else
var3 = Replace(var3, "%3a", ":")
var3 = Replace(var3, "%20", " ")
var3 = Replace(var3, "%2f", "/")
var3 = Replace(var3, "%2e", ".")
var3 = Replace(var3, "%2d", "-")
var3 = Replace(var3, "%3f", "?")
var3 = Replace(var3, "%3d", "=")
var3 = Replace(var3, "%5f", "_")
var3 = Replace(var3, "%26", "&")
var3 = Replace(var3, "%23", "#")
var3 = Replace(var3, "%7e", "~")
var3 = Replace(var3, "%2b", "+")
var3 = Replace(var3, "%25", "%")
var3 = Replace(var3, "%3a", ":")
var4 = Mid(var3, InStr(var3, "url=") + 4, InStr(var3, "&_dci_setc") - (InStr(var3, "url=") + 4))
End If
End If
If InStr(var3, "nunry.asp?") > 0 Then
near = Mid(var3, InStr(var3, "nunry.asp?"))
End If
Next
ctr1 = 0
For i = 128 To 255
k = InStrRev(temp1, Chr(i))
ctr = 0
l = 1
For j = 1 To k
If InStr(l, temp1, Chr(i)) > 0 Then
l = l + InStr(l, temp1, Chr(i))
ctr = ctr + 1
End If
Next
If ctr > 0 Then
Print(2, rec("vid").Value & Chr(9) & i & Chr(9) & Chr(i) & Chr(9) & ctr)
ctr1 = ctr1 + ctr
End If
Next
If ctr1 > 0 Then
Write(2, "No. of Spl Characters : " & Chr(9) & ctr1)
End If
Print(2, temp1)
Print(2)
Print(2, "**********************************************************************************************************************************")
*****Portion to Grab Images******
If imgavbl = "Y" Then
source = "http://www.blahblahblah.com/emnt_eus_ew/" & rec("vid").Value
localpath = "c:\dcartgalleriesimg\" & rec("vid").Value & ".jpg"
Open localpath For Binary As #1
For z = 0 To UBound(bdata)
Put #1, , bdata(z)
Next
Close #1
End If
bdata = inetIMAGE.OpenURL(source, icByteArray)
Open localpath For Binary As #1
For z = 0 To UBound(bdata)
Put #1, , bdata(z)
Next
Close #1
cn.Execute ("update table set imagestatus = " & imgavbl & " where vid = " & rec("vid") & "")
cn.Execute("update table set desc1 = " & temp1 & ",title = " & temp & ",officialurl = " & var4 & ",imagestatus = " & imgavbl & ", maplink = " & map & ",nearbylink = " & near & " where vid = " & rec("vid").Value & "")
source = ""
objDoc = Nothing
objTEXT = Nothing
temp1 = ""
temp = ""
map = ""
near = ""
imgavbl = ""
var4 = ""
Erase bdata()
End If
End If
rec.MoveNext()
End While
Close #2
MsgBox("Done")
End
End Sub
End Class