cartch2007
New member
- Joined
- Jun 18, 2007
- Messages
- 1
- Programming Experience
- 5-10
Hello,
I have an app that was written using vb.net 2003 that is working great. I have the same app (same code) written and compiled in visual studio 2005 that does not work. The problem is that I am receiving the "Unable to connect to the remote server" error. You'll see in the code that I connect to the remote box in the loop. It will connect some of the time, but, eventually I will get the error. I do not get the error at the same point of the loop each time I run. Like I said, this works when the app is compiled in vb 2003. Any help would be appreciated
I have an app that was written using vb.net 2003 that is working great. I have the same app (same code) written and compiled in visual studio 2005 that does not work. The problem is that I am receiving the "Unable to connect to the remote server" error. You'll see in the code that I connect to the remote box in the loop. It will connect some of the time, but, eventually I will get the error. I do not get the error at the same point of the loop each time I run. Like I said, this works when the app is compiled in vb 2003. Any help would be appreciated
VB.NET:
For Each dr As DataRow In dtInv.Rows
strStyleNum = CType(dr("StyleNum"), String)
strVendorName = CType(dr("RunItVendorName"), String)
lngInventoryID = CType(dr("InventoryID"), Long)
strColorDesc = CType(dr("ColorDesc"), String)
strSizeDesc = CType(dr("SizeDesc"), String)
strSend = "StoreID=" & HttpUtility.UrlEncode(UCase(strStoreID)) & "&Brand=" & HttpUtility.UrlEncode(UCase(strVendorName)) & "&Style=" _
& HttpUtility.UrlEncode(UCase(strStyleNum)) & "&Ext=" & HttpUtility.UrlEncode(UCase(strColorDesc)) & "&Size=" & HttpUtility.UrlEncode(UCase(strSizeDesc))
intInvCount = GetInvCount(strSend, dateServerDateTime)
InsertLog(strStyleNum, strVendorName, lngInventoryID, strColorDesc, strSizeDesc, intInvCount, dateRunTime, dateRunItServerDateTime)
UpdateInventory(lngInventoryID, intInvCount)
Next
VB.NET:
Function GetInvCount(ByVal strSend As String, ByRef dateServerDateTime As DateTime) As Integer
Try
Dim strUrl As String = "http://remoteserver"
Dim objWebRequest As HttpWebRequest = HttpWebRequest.Create(strUrl)
objWebRequest.Method = "POST"
objWebRequest.ContentLength = strSend.Length
objWebRequest.ContentType = "application/x-www-form-urlencoded"
objWebRequest.Timeout = 200000
objWebRequest.ReadWriteTimeout = 200000
Dim encoding As New Text.ASCIIEncoding
Dim streamWriter = New StreamWriter(objWebRequest.GetRequestStream(), encoding)
streamWriter.Write(strSend)
streamWriter.Close()
Dim webresponse As HttpWebResponse = objWebRequest.GetResponse
webresponse.Close()
dateRunItServerDateTime = Convert.ToDateTime(webresponse.Headers("Date"))
Return Convert.ToInt32(webresponse.Headers.Item("Available"))
Catch ex As WebException
'send me an email
MsgBox(ex.Message.ToString)
End
End Try
End Function