.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Velemoochi
Imran Ghani
Post New Web Links

writing if statement for proxy

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :.NET Framework
 
Hi guys, I would like to know how I could write on the if statement to check with the proxy wether if they are required for the username and password? Here it is the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create a new request to the mentioned URL. Dim a As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://whatismyip.com/automation/n09230945.asp"), HttpWebRequest) ' Obtain the 'Proxy' of the Default browser. Dim Proxy As New WebProxy(Address1.Text, Integer.Parse(Ports.Text)) ' Print the Proxy Url to the console. Dim myProxy As New WebProxy() Try If Address1.Text Is Nothing Then MsgBox("plz enter the address and ports") Else a.Proxy = New WebProxy(Address1.Text, Integer.Parse(Ports.Text)) Dim c As HttpWebResponse = DirectCast(a.GetResponse(), HttpWebResponse) Dim reader As New StreamReader(c.GetResponseStream()) Dim ip As String = reader.ReadToEnd() MsgBox(ip) If Proxy.Credentials.GetCredential Then myProxy.Credentials = New NetworkCredential(Username.Text, Password.Text) a.Proxy = Proxy End If End If Catch ex As Exception MsgBox("proxy server fails") End Try End Sub As I am stored the username and password in the textbox. As the code I have already wrote, it won't response to the proxy by response with the us


View Complete Post


More Related Resource Links

writing if statement for proxy

  
Hi guys, I would like to know how I could write on the if statement to check with the proxy wether if they are required for the username and password? Here it is the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create a new request to the mentioned URL. Dim a As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://whatismyip.com/automation/n09230945.asp"), HttpWebRequest) ' Obtain the 'Proxy' of the Default browser. Dim Proxy As New WebProxy(Address1.Text, Integer.Parse(Ports.Text)) ' Print the Proxy Url to the console. Dim myProxy As New WebProxy() Try If Address1.Text Is Nothing Then MsgBox("plz enter the address and ports") Else a.Proxy = New WebProxy(Address1.Text, Integer.Parse(Ports.Text)) Dim c As HttpWebResponse = DirectCast(a.GetResponse(), HttpWebResponse) Dim reader As New StreamReader(c.GetResponseStream()) Dim ip As String = reader.ReadToEnd() MsgBox(ip) If Proxy.Credentials.GetCredential Then myProxy.Credentials = New NetworkCredential(Username.Text, Password.Text) a.Proxy = Proxy End If End If Catch ex As Exception MsgBox("proxy server fails") End Try End Sub As I am stored the username and password in the textbox. As the code I have already wrote, it won't response to the proxy by response with the us

Writing openquery with select statement for Informix DB which to set dirty read

  

Hi,

I currently have an openquery statement that gets data from an informix database.  We are experiencing issues with not getting all of the data.  We would like to add a set isolation to dirty read statement.  Just can't seem to get the Informix statement to work with the T-SQL openquery statement:

Original statement:

SELECT

 

loc, container, [order], po, parcelcarr,

Writing multiple if statement in where clause in Stored Procedure

  

Hi,

I have one Stored Procedure which returns some value. now i have some different conditions in my select query so can i write them in my where clause instead of writing the whole select query again for different conditions? 

Like 

My Current Select Statement in SP looks like :

Select

         FName,LName,UniqueRef,City

From 

       tblContact

Where 

     UniqueRef='@UniqueRef'

 

Now i have two more conditions in my Select Statement that are

@ProductList varchar(max),

@StatusList Varchar(max)

and they gets the list of id of their name from another function that is made for them respectively fun_GetProductId and fun_GetStatusId

so with this my Select Statement in SP will look like 

Select

         FName,LName,UniqueRef,City

From 

       tblContact

Where 

     (UniqueRef='@UniqueRef' or @UniqueRef='') and 

    (Productid in (Select * From fun_GetProductId(@ProductList))) and

   (StatusId in (Select * From fun_GetStatusId(@StatusList))) 


Writing custom MembershipProvider

  
ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class.
Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc.

10 Tips for Writing High-Performance Web Applications

  
Writing a Web application with ASP.NET is unbelievably easy. So easy, many developers don't take the time to structure their applications for great performance. In this article, I'm going to present 10 tips for writing high-performance Web apps. I'm not limiting my comments to ASP.NET applications because they are just one subset of Web applications. This article won't be the definitive guide for performance-tuning Web applications-an entire book could easily be devoted to that. Instead, think of this as a good place to start.

Writing Custom Web Parts for SharePoint 2007

  
As I mentioned in an earlier blog post, SharePoint 2007 is built on top of ASP.NET 2.0, which means you can now use ASP.NET 2.0 features (Forms Authentication, Master Pages, Membership, Site Navigation, New Data Controls, etc) when building SharePoint sites. This is true for both the new Windows SharePoint Services 3.0 version (which will be a free download) as well as Microsoft Office SharePoint Server 2007 (which costs money).

Reading and Writing Images From a Windows Mobile Database using UltraLite 10(C#)

  
Periodically I get a request for information on how to read and write binary data to a database running on Windows Mobile. If you search the Internet you can typically find examples that are available on Windows Desktops or allow you to read and write to a local file system. The problem is that it can take a bit of work to get this code to work on Windows Mobile accessing a database.

Ultimately you might be asking, why would I want to store and image in a database? Well in an environment where you synchronizing data between a local mobile database and a consolidated (central) database this can be extremely useful. Imagine if an insurance adjuster went to an accident scene, took a picture of a damaged car, loaded it into his Windows Mobile database and then replicated that image up to the Insurance headquarters for approval. All of this could be done in a very short period of time when using images in the database. Another good example might be a doctor who was waiting for a patient chart to become available. If you could store the image in a database this chart could be sent down to the doctor's device once it became available.

For this article I am not going to get into how to synchronize the images to and from a remote and central database as this is typically fairly straightforward when using a data synchronization technologies like MobiLink

XML Reading and Writing

  
We learned to process XML files using the Document Object Model as implemented by the XmlDocument class. To go further and make XML friendlier, the .NET Framework provides many other classes for different purposes, allowing you to create and manage nodes from custom .NET classes.
Besides the XmlDocument and the derived classes of XmlNode, the .NET Framework provides the XmlTextWriter class, which is derived from XmlWriter. The XmlTextWriter class works in a top-down approach to create, or deal with, the contents of an XML file. This class writes an XML node and moves down without referring

Writing Http Handlers and Modules in IIS 7.5

  
This article describes how Http modules and handlers are to be written and configured in IIS 7.5. The concept of a handler and module remains same, so dose there programming model. In this section we start off with the concept of a Http module and a Http handler, then talk about how to code them and finally describe the two methods available to configure them.

Passing Linq Statement between master and content page

  

I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
        Get
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result
   'then

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
        Else
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub


On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If


m.searchRes is always nothing. 

What am I doing wrong here?

Thanks


file upload in chunks or not buffering in memory before writing to disk?

  

What are the options for handling file uploads to reduce the memory footprint?  Is there a way to upload in chunks?  Is there a way to stream upload directly to disk instead of loading entire file in server memory?


Thanks


deploying to msdeploy does not support a proxy server

  

I am trying to deploy through webmatrix but my system Proxy server configuration is not being used. I assume that webmatrix would detect the proxy server settings and use that for the msdeploy calls under the hood. Can anyone confirm this is a know issue? 


Writing codes using three tier architecture.

  

Hello all.

I am a beginner in c#.I heard that writing program with three tier architecture are easy and maintainable.

I just wanted to know with a small example on how to write three tier architecture programs.


Thanks :-)


ReportViewer :: Failed to enable constraints. But my statement is valid!!

  
  • A
  • n error has occurred during report processing.
      • Exception has been thrown by the target of an invocation.
        • Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Why do I keep getting this error, even when not using any data on the report. When I run the query in SQL server I get a resultset. However when I try to render the report I get this error.

    Thanks!


    Whats wrong with this statement

      

    Im trying to updated some old ASP pages with some new .net pages and cant seem to get this update statement to work. I need to update the current ASP code below and then once thats working im going to use that same statement in a procedure for all our new .Net pages..

    So can anyone see what im doing wrong by inserting the 2nd column to the update statement?

    strSqual = "update tas set date_completed='" & TransDate & ", trans_id=" & InsertedTransID & "' where date_completed is null and sercontract_id="& strContractID & " and DATEDIFF(dd,task_due_date,'" & strProcDate & "')<=14"

     

    I am trying to add an extra column to the update, but not sure if the syntax is correct.

    If Statement Issue

      

    Hi,

    This is very strange to me. I have spent 2hrs looking into this inside out , but dont seem to get it

    I have an if statement that inserts data into the database. But i check to make sure the name is not entered twice. Now when the name is already in the db, then it should insert else put out a message saying its already in the db

    My code works fine except that  when its not in the db, its inserts but still puts out the message that says "Name is already in use" Not sure if am not seeing something. But thought i did bring it to the forum. Here is my code...Pretty simple

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

            Dim objConnection As SqlConnection
            Dim objCommand As SqlCommand
            Dim strSQLQuery1 As String

     

            ' If there's nothing to Add for then don't search
            ' o/w build our SQL Query and execute it.
            If String.IsNullOrEmpty(txtAdd.Text) Or Leadbank.SelectedValue = "000" Then

              

    statement cannot appear outside of a method body

      

    hi all,

      i am posting my vb.net problem .plz tell me how to resolve this :-


    Dim conn As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
        'Dim mysqlconnection As New SqlConnection(conn)
        'If mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();
        'Dim mySqlcommand As New SqlCommand("select CategoryId,CategoryName from Categories", mysqlconnection)
        'Dim mySqlDataAdapter As New SqlDataAdapter(mySqlcommand)
        'Dim mydataSet As New DataSet()
        'mySqlDataAdapter.Fill(mydataSet);

        'Gridview1.DataSource=ds;
        'Gridview1.DataBind();
        'if mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();

    i m getting 5 errors in this code

    declaration expected in mySqlDataAdapter.Fill method; Gridview1.DataSource=ds; Gridview1.DataBind();


    Categories: 
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend