I want to call java servlet from from my vb 6.0 code. I have tu use the URL of the servelet on remote machine and display the message after execution of the program.
Private Sub Command3_Click()
Dim req As WinHttp.WinHttpRequest
Dim buffer As Variant
Set req = New WinHttp.WinHttpRequest
req.SetTimeouts 1800000, 1800000, 1800000, 1800000
req.Open "POST", "http://www.google.co.in", False
buffer = "tusharp 0"
req.Send cmbuffer
Debug.Print req.ResponseText
End Sub
Try this.....
Using following bunch of code you can simply call servlet by using URL. You can pass parameters via appropriate method.
**Private Function ExecuteSQL(ByVal sSQL As String, ByVal bResultSet As Boolean) As String
Dim http As Object
Dim strURL As String
Dim strPostData As String
Dim strHeader As String
Dim strResponse As String
On Error GoTo Err
Screen.MousePointer = vbHourglass
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
strPostData = "?Command=" & IIf(bResultSet, "SELECT", "UPDATE") & "&SQL=" & sSQL
strURL = "http://localhost:8080/FirstProject/DBConnector" & strPostData
http.setTimeouts 10000, 10000, 10000, 10000 'For some reason times out sooner than this sometimes
http.Open "POST", strURL, False
http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send strPostData
strResponse = http.ResponseText
Screen.MousePointer = vbDefault
ExecuteSQL = strResponse
Exit Function
Related
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection
Dim dbProvider As String = "Provider=Microsoft.ACE.OLEDB.12.0;"
Dim dbSource As String = "Data Source=D:\Visual Basic\dito\Database2.accdb;"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.ConnectionString = dbProvider & dbSource
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox3.Text = Nothing Or TextBox4.Text = Nothing Then
MessageBox.Show("Please enter details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If con.State = ConnectionState.Closed Then
con.Open()
End If
Using cmd As New OleDbCommand("SELECT COUNT(*)FROM member WHERE [USERNAME] = #USERNAME OR [PASSWORD] = #PASSWORD", con)
cmd.Parameters.AddWithValue("#USERNAME", OleDbType.VarChar).Value = TextBox3.Text
cmd.Parameters.AddWithValue("#PASSWORD", OleDbType.VarChar).Value = TextBox4.Text
Dim count = Convert.ToInt32(cmd.ExecuteScalar())
If count > 0 Then
MessageBox.Show("oops, username and password has already been taken", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
End Using
Using create As New OleDbCommand("INSERT INTO member(USERNAME], [PASSWORD])VALUES(#USERNAME,PASSWORD)")
create.Parameters.AddWithValue("#USERNAME", OleDbType.VarChar).Value = TextBox3.Text
create.Parameters.AddWithValue("#PASSWORD", OleDbType.VarChar).Value = TextBox4.Text
If create.ExecuteNonQuery Then
MessageBox.Show("Account created", "information", MessageBoxButtons.OK, MessageBoxIcon.Information)
TextBox3.Clear()
TextBox4.Clear()
End If
End Using
con.Close()
End Sub
End Class
pls help dont know what to do
i'm a junior developer and i started working recently.
They put me on this LEGACY program and asked me to try and resolve this problem.
They strictly forbid me of using CLOB.
Dim fs As Stream = PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(Convert.ToInt32(fs.Length))
pdfComunication = pdfConvert(bytes)
pdfComunication = bytes
idOperator = ViewState("idOperator")
'
Private Function pdfConvert(ByVal document As Byte()) As Byte()
Dim doc As Byte()
Using msRtf As MemoryStream = New MemoryStream(document)
Dim dc As softDocument.DocumentCore = softDocument.DocumentCore.Load(msRtf, New softDocument.DocxLoadOptions())
Using msDocx As MemoryStream = New MemoryStream()
dc.Save(msDocx, New softDocument.PdfSaveOptions())
doc = msDocx.ToArray()
End Using
End Using
Return doc
End Function
'
<WebMethod()>
Public Function InsertComunications(ByVal pIdComunicationType As Integer, ByVal pAwaitingStatus As Integer, ByVal pRequestingUser As String, ByVal pIdSr As String,
ByVal pItem As String, ByVal pText As String, ByVal pCommonSender As String, pPecSender As String, ByVal pDestination As String,
ByVal pPdfComunication As Byte()) As String
Dim dbConn As New OracleConnection
Dim cmd As New OracleCommand
Dim errMsg As String = String.Empty
dbConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("DBConn").ToString
Try
dbConn.Open()
cmd.Parameters.Clear()
cmd.CommandText = ""
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Connection = dbConn
Dim p_IdComunicationType As New System.Data.OracleClient.OracleParameter("p_IdComunicationType ", System.Data.OracleClient.OracleType.Number)
p_IdComunicationType.Direction = ParameterDirection.Input
p_IdComunicationType.Value = pIdComunicationType
cmd.Parameters.Add(p_IdComunicationType)
Dim p_AwaitingStatus As New System.Data.OracleClient.OracleParameter("p_AwaitingStatus", System.Data.OracleClient.OracleType.Number)
p_AwaitingStatus.Direction = ParameterDirection.Input
p_AwaitingStatus.Value = pAwaitingStatus
cmd.Parameters.Add(p_AwaitingStatus)
Dim p_RequestingUser As New System.Data.OracleClient.OracleParameter("p_RequestingUser ", System.Data.OracleClient.OracleType.NVarChar)
p_RequestingUser.Direction = ParameterDirection.Input
p_RequestingUser.Value = pRequestingUser
cmd.Parameters.Add(p_RequestingUser)
Dim p_IdSr As New System.Data.OracleClient.OracleParameter("p_IdSr", System.Data.OracleClient.OracleType.NVarChar)
p_IdSr.Direction = ParameterDirection.Input
p_IdSr.Value = pIdSr
cmd.Parameters.Add(p_IdSr)
Dim p_Item As New System.Data.OracleClient.OracleParameter("p_Item", System.Data.OracleClient.OracleType.NVarChar)
p_Item.Direction = ParameterDirection.Input
p_Item.Value = pItem
cmd.Parameters.Add(p_Item)
Dim p_Text As New System.Data.OracleClient.OracleParameter("p_Text", System.Data.OracleClient.OracleType.NVarChar)
p_Text.Direction = ParameterDirection.Input
p_Text.Value = pText
cmd.Parameters.Add(p_Text)
Dim p_CommonSender As New System.Data.OracleClient.OracleParameter("p_CommonSender", System.Data.OracleClient.OracleType.NVarChar)
p_CommonSender.Direction = ParameterDirection.Input
p_CommonSender.Value = pCommonSender
cmd.Parameters.Add(p_CommonSender)
Dim p_PecSender As New System.Data.OracleClient.OracleParameter("p_PecSender", System.Data.OracleClient.OracleType.NVarChar)
p_PecSender.Direction = ParameterDirection.Input
p_PecSender.Value = pPecSender
cmd.Parameters.Add(p_PecSender)
Dim p_Destination As New System.Data.OracleClient.OracleParameter("p_Destination", System.Data.OracleClient.OracleType.NVarChar)
p_Destination.Direction = ParameterDirection.Input
p_Destination.Value = pDestination
cmd.Parameters.Add(p_Destination)
Dim p_PdfComunication As New System.Data.OracleClient.OracleParameter("p_PdfComunication", System.Data.OracleClient.OracleType.Blob)
p_PdfComunication.Direction = ParameterDirection.InputOutput
p_PdfComunication.Value = pPdfComunication
cmd.Parameters.Add(p_PdfComunication)
cmd.ExecuteNonQuery()
Finally
dbConn.Dispose()
cmd.Dispose()
End Try
'
The problem is that the file size is too big for the blob in the db, which is strange since in other parts of the program that don't do the conversion it takes files way bigger than the ones i'm trying right now...
Any suggestions?
'EDIT
TYPE t_Cursor IS REF CURSOR;
PROCEDURE GetMailTemplate(Cur_Out OUT t_Cursor);
PROCEDURE 1(p_IdComunicationType IN NUMBER,
p_AwaitingStatus IN NUMBER,
p_RequestingUser IN VARCHAR2,
p_IdSr IN VARCHAR2,
p_Item IN VARCHAR2,
p_Testo IN VARCHAR2,
p_CommonSender IN VARCHAR2,
p_PecSender IN VARCHAR2,
p_Destination IN VARCHAR2,
p_PdfComunication xx.PDF_COMUNICATION%Type
);
PROCEDURE 2( p_AwaytingStatus NUMBER, Cur_Out OUT t_Cursor);
PROCEDURE 3(p_IdComunicationType VARCHAR2,
p_AwaitingStatus NUMBER);
We finally found an answer, we had to put everything inside a TRANSACTION:
Public Function InsertComunications(ByVal pIdComunicationType As Integer, ByVal pAwaitingStatus As Integer, ByVal pRequestingUser As String, ByVal pIdSr As String,
ByVal pItem As String, ByVal pText As String, ByVal pCommonSender As String, pPecSender As String, ByVal pDestination As String,
ByVal pPdfComunication As Byte()) As String
Dim dbConn As New OracleConnection
**Dim trns as System.Data.OracleClient.OracleTransaction = Nothing**
Dim cmd As New OracleCommand
Dim errMsg As String = String.Empty
dbConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("DBConn").ToString
Try
dbConn.Open()
**trns = dbConn.BeginTransaction**
**cmd.Transaction = trns**
cmd.Parameters.Clear()
cmd.CommandText = ""
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Connection = dbConn
Dim p_IdComunicationType As New System.Data.OracleClient.OracleParameter("p_IdComunicationType ", System.Data.OracleClient.OracleType.Number)
p_IdComunicationType.Direction = ParameterDirection.Input
p_IdComunicationType.Value = pIdComunicationType
cmd.Parameters.Add(p_IdComunicationType)
Dim p_AwaitingStatus As New System.Data.OracleClient.OracleParameter("p_AwaitingStatus", System.Data.OracleClient.OracleType.Number)
p_AwaitingStatus.Direction = ParameterDirection.Input
p_AwaitingStatus.Value = pAwaitingStatus
cmd.Parameters.Add(p_AwaitingStatus)
Dim p_RequestingUser As New System.Data.OracleClient.OracleParameter("p_RequestingUser ", System.Data.OracleClient.OracleType.NVarChar)
p_RequestingUser.Direction = ParameterDirection.Input
p_RequestingUser.Value = pRequestingUser
cmd.Parameters.Add(p_RequestingUser)
Dim p_IdSr As New System.Data.OracleClient.OracleParameter("p_IdSr", System.Data.OracleClient.OracleType.NVarChar)
p_IdSr.Direction = ParameterDirection.Input
p_IdSr.Value = pIdSr
cmd.Parameters.Add(p_IdSr)
Dim p_Item As New System.Data.OracleClient.OracleParameter("p_Item", System.Data.OracleClient.OracleType.NVarChar)
p_Item.Direction = ParameterDirection.Input
p_Item.Value = pItem
cmd.Parameters.Add(p_Item)
Dim p_Text As New System.Data.OracleClient.OracleParameter("p_Text", System.Data.OracleClient.OracleType.NVarChar)
p_Text.Direction = ParameterDirection.Input
p_Text.Value = pText
cmd.Parameters.Add(p_Text)
Dim p_CommonSender As New System.Data.OracleClient.OracleParameter("p_CommonSender", System.Data.OracleClient.OracleType.NVarChar)
p_CommonSender.Direction = ParameterDirection.Input
p_CommonSender.Value = pCommonSender
cmd.Parameters.Add(p_CommonSender)
Dim p_PecSender As New System.Data.OracleClient.OracleParameter("p_PecSender", System.Data.OracleClient.OracleType.NVarChar)
p_PecSender.Direction = ParameterDirection.Input
p_PecSender.Value = pPecSender
cmd.Parameters.Add(p_PecSender)
Dim p_Destination As New System.Data.OracleClient.OracleParameter("p_Destination", System.Data.OracleClient.OracleType.NVarChar)
p_Destination.Direction = ParameterDirection.Input
p_Destination.Value = pDestination
cmd.Parameters.Add(p_Destination)
Dim p_PdfComunication As New System.Data.OracleClient.OracleParameter("p_PdfComunication", System.Data.OracleClient.OracleType.Blob)
p_PdfComunication.Direction = ParameterDirection.InputOutput
p_PdfComunication.Value = pPdfComunication
cmd.Parameters.Add(p_PdfComunication)
cmd.ExecuteNonQuery()
**trns.Commit()**
Finally
dbConn.Dispose()
cmd.Dispose()
End Try
so this code works with just the out parameter but then when you add in parameters weird nulls start showing up and also the straight in parameters work too so it is just when there are both in and out parameters.
the part with problems is the in and out parameters do not want to coexist
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
For Each kvp As KeyValuePair(Of String, String) In sqlParams
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Output)
newParam.Size = 400
cmd.Parameters.Add(newParam)
Next
This works
Public Shared Sub Run_Oracle_Query(ByVal queryToRun As String, ByVal sqlParams As Dictionary(Of String, String))
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
Dim con As OracleConnection = New OracleConnection(dbConnString)
Dim cmd = con.CreateCommand()
Try
con.Open()
cmd.CommandText = queryToRun
cmd.CommandType = CommandType.Text
For Each kvp As KeyValuePair(Of String, String) In sqlParams
cmd.Parameters.Add(kvp.Key, kvp.Value)
Next
cmd.ExecuteNonQuery()
'log all sql queryies very expensive operation
LogThisString("Log All queries: " & queryToRun, "Always")
Catch ex As OracleException ' catches only Oracle errors
OracleExceptionLogging(ex.Number, queryToRun, ex)
Catch ex As Exception
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
' MsgBox("Could Not Perform This Database Operation")
Finally
con.Close()
cmd.Dispose()
con.Dispose()
End Try
End Sub
This works
Public Shared Function Run_Insert_Oracle_Query_Return_ID(ByVal queryToRun As String, ByVal IDcolumnName As String) As String
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
Dim con As OracleConnection = New OracleConnection(dbConnString)
Dim cmd = con.CreateCommand()
Dim strUkey As String = ""
Try
con.Open()
cmd.CommandText = queryToRun & " RETURNING " & IDcolumnName & " INTO :UKEY"
cmd.CommandType = CommandType.Text
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
cmd.ExecuteNonQuery()
strUkey = cmd.Parameters("PKEY").Value.ToString
Return strUkey
Catch ex As OracleException ' catches only Oracle errors
OracleExceptionLogging(ex.Number, queryToRun, ex)
Catch ex As Exception
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
PopupMsgBox("Database Error", "Database Integrity Constants Violated SQL Operation Will Not Be Executed")
Finally
con.Close()
cmd.Dispose()
con.Dispose()
End Try
Return strUkey
End Function
This does not work
Public Shared Function Run_Insert_Oracle_Query_Return_ID(ByVal queryToRun As String, ByVal IDcolumnName As String, ByVal sqlParams As Dictionary(Of String, String)) As String
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
Dim con As OracleConnection = New OracleConnection(dbConnString)
Dim cmd = con.CreateCommand()
Dim strUkey As String = ""
Try
con.Open()
cmd.CommandText = queryToRun & " RETURNING " & IDcolumnName & " INTO :UKEY"
cmd.CommandType = CommandType.Text
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
For Each kvp As KeyValuePair(Of String, String) In sqlParams
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Output)
newParam.Size = 400
cmd.Parameters.Add(newParam)
Next
cmd.ExecuteNonQuery()
strUkey = cmd.Parameters("PKEY").Value.ToString
Return strUkey
Catch ex As OracleException ' catches only Oracle errors
OracleExceptionLogging(ex.Number, queryToRun, ex)
Catch ex As Exception
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
PopupMsgBox("Database Error", "Database Integrity Constants Violated SQL Operation Will Not Be Executed")
Finally
con.Close()
cmd.Dispose()
con.Dispose()
End Try
Return strUkey
End Function
crap so i guess it does look for order asnd the output does need to be at end like this.....this works solved my own problem
For Each kvp As KeyValuePair(Of String, String) In sqlParams
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Input)
newParam.Size = 400
cmd.Parameters.Add(newParam)
Next
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
I am dynamically building a datatable and binding it to a gridview in a VB codebehind. I transform the gridview cell data into LinkButton controls to allow that data to be clicked for updates.
I am using AjaxControlToolkit to present a modal popup to collect data updates. Once those updates are completed, I rebuild the datatable and databind the gridview. In Gridview.RowCreated, I repeat the creation of the LinkButton controls on postback.
When the page is presented following an update, when I click on a LinkButton the postback happens but RowCommand is not fired. While debugging, I notice that when this occurs, Page.FindControl() cannot locate the targeted LinkButton control.
The page is returned without firing the RowCommand event to trigger the display of the modal popup. If I simply press the LinkButton a second time, the LinkButton control can be found using Page.FindControl() and RowCommand fires as desired.
What am I missing? Thanks much for any ideas to resolve this issue. I have struggled with this all day and I'm running out of ideas.
Thank you!
Here is requested code:
<asp:GridView ID="CustomeGridview" GridLines="Vertical" Width="100%" runat="server"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" AutoGenerateColumns="true" ForeColor="Black" ShowHeader="False" Font-Names="Verdana"
Font-Size="11px" OnRowCommand="CustomeGridview_RowCommand"
OnRowDataBound="CustomeGridview_RowDataBound">
<FooterStyle BackColor="#CCCCCC" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.CacheControl = "no-cache"
Response.Expires = -1
Response.AddHeader("Pragma", "no-cache")
If Page.IsPostBack = False Then
ViewState("Left") = 3
ViewState("Right") = 6
generateManualDt()
Else
Dim controlName As String = Request.Params.Get("__EVENTTARGET")
Dim ctl As Control = Page.FindControl(controlName)
End If
Page_Header_Label.Text = "Action Qualification Matrix - " & Session("CurrentServiceName")
FormatColumns()
End Sub
Public Sub generateManualDt()
Dim ManualDt As DataTable = BuildMainDataTable()
ViewState("ManualDt") = ManualDt
CustomeGridview.DataSource = ManualDt
CustomeGridview.DataBind()
SetJumpScrollButtons()
End Sub
Protected Sub CustomeGridview_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles CustomeGridview.RowDataBound
Dim dt As DataTable = DirectCast(ViewState("ManualDt"), DataTable)
Dim dtsnocol As DataTable = DirectCast(ViewState("dtsnocol"), DataTable)
If e.Row.RowType = DataControlRowType.DataRow OrElse e.Row.RowType = DataControlRowType.Header Then
For gvCol As Integer = 7 To dt.Columns.Count - 1
e.Row.Cells(gvCol).Visible = False
Next
SetupGridRowControls(e, dtsnocol, dt)
End If
End Sub
Protected Sub CustomeGridview_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles CustomeGridview.RowCreated
Dim dt As DataTable = DirectCast(ViewState("ManualDt"), DataTable)
Dim dtsnocol As DataTable = DirectCast(ViewState("dtsnocol"), DataTable)
e.Row.Cells(0).Visible = False ' Hide the QuestionID column
If Page.IsPostBack Then
If e.Row.RowType = DataControlRowType.DataRow OrElse e.Row.RowType = DataControlRowType.Header Then
SetupGridRowControls(e, dtsnocol, dt)
End If
End If
End Sub
Private Sub SetupGridRowControls(ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs, ByRef dtsnocol As DataTable, ByRef mainDt As DataTable)
Dim CurrSnoCount As Integer = 0
If Not dtsnocol Is Nothing Then
CurrSnoCount = dtsnocol.Rows.Count
End If
If e.Row.DataItemIndex = 0 Then ' Scenario Number row
Dim snoLabel As New Label()
snoLabel.Text = "SCENARIO "
snoLabel.ID = "snoHdrLabel"
e.Row.Cells(2).Controls.Add(snoLabel)
Dim addScenarioBtn = buildAddButton("AddScenario", "", "Click to add a new scenario column")
e.Row.Cells(2).Controls.Add(addScenarioBtn)
ElseIf e.Row.DataItemIndex = 1 Then ' Question Header and Sno Descriptions
Dim questLabel As New Label()
questLabel.Text = "QUESTIONS "
questLabel.ID = "questdrLabel"
e.Row.Cells(2).Controls.Add(questLabel)
Dim addQuestionBtn = buildAddButton("AddQuestion", "", "Click to add a new question row")
e.Row.Cells(2).Controls.Add(addQuestionBtn)
Dim cellText As String = ""
Dim snoId As String = ""
For snoRowIdx As Integer = 0 To CurrSnoCount - 1
snoId = dtsnocol.Rows(snoRowIdx)("ScenarioID").ToString()
cellText = dtsnocol.Rows(snoRowIdx)("Note").ToString()
Dim lnkBtn = buildLinkButton("EditScenario", snoId, cellText)
e.Row.Cells(snoRowIdx + 3).Controls.Add(lnkBtn)
Next
ElseIf e.Row.DataItemIndex > 1 Then ' Question / Responses
Dim cellText As String = ""
Dim cellAddr As String = ""
Dim snoId As String = ""
Dim questId As String = mainDt.Rows(e.Row.DataItemIndex).Item(0).ToString.Trim
For snoRowIdx As Integer = 0 To CurrSnoCount - 1
snoId = dtsnocol.Rows(snoRowIdx)("ScenarioID").ToString.Trim
cellAddr = String.Format("{0}:{1}", questId, snoId)
cellText = mainDt.Rows(e.Row.DataItemIndex).Item(snoRowIdx + 3).ToString.Trim
Dim lnkBtn = buildLinkButton("EditResponses", cellAddr, cellText)
e.Row.Cells(snoRowIdx + 3).Controls.Add(lnkBtn)
Next
End If
End Sub
Private Function buildLinkButton(ByVal linkCmd As String, ByVal linkCmdArg As String, ByVal linkText As String) As LinkButton
Dim lnkBtn As New LinkButton()
lnkBtn.Text = linkText
lnkBtn.CommandName = linkCmd
lnkBtn.CommandArgument = linkCmdArg
lnkBtn.ToolTip = "Click to update"
lnkBtn.CssClass = "cell_link"
Return lnkBtn
End Function
Private Function buildAddButton(ByVal btnCmd As String, ByVal btnCmdArg As String, ByVal btnToolTip As String) As ImageButton
Dim imgBtn As New ImageButton()
imgBtn.CommandName = btnCmd
imgBtn.CommandArgument = btnCmdArg
imgBtn.ImageUrl = "~/Images/services/SmallAddBtn.gif"
imgBtn.ToolTip = btnToolTip
imgBtn.ID = String.Format("{0}_GenImageButton", btnCmd)
Return imgBtn
End Function
I am trying to make httpwebrequests using a list of proxy ips, but each time I make a request I get an error message : Unable to connect to the remote server.
Here is a sample of my code:
Dim request as HttpWebRequest = WebRequest.Create(url)
Dim oldProxy as IWebProxy = CType(request.Proxy, IWebProxy)
Dim proxy as New WebProxy()
Dim newuri as new Uri("http://" & proxyIP)
proxy.Address = newuri
request.Proxy = proxy
request.Proxy.Credentials = CredentialCache.DefaultCredentials
Try
request.Timeout=18000
request.UserAgent = useragent
request.KeepAlive = False
**webreponse = tryCast(request.GetResponse(), HttpWebResponse)**
request.accept="*/*"
...
It fails on the request.getresponse line above. Any ideas appreciated.
figured it out changed the code...
Dim request as HttpWebRequest = WebRequest.Create(url)
Dim proxy as New WebProxy()
Dim newuri as new Uri("http://" & proxyIP)
request.Proxy = proxy
Try
request.Method="GET"
request.Timeout=18000
request.UserAgent = useragent
request.KeepAlive = False
**webreponse = tryCast(request.GetResponse(), HttpWebResponse)**
request.accept="*/*"