locked
Convert code from VB.net to ASP.net RRS feed

  • Question

  • Hi,
    I have recently moved from desktop aapplications to ASP.net.  I used to use the following code to filter my dataset to retrieve the proper data.  the code is in Load event :

    Dim DsProducts As New DataSet
        Sub GetProducts()
            Dim cnn As New SqlConnection(ConnectionString)
            Dim cmd As New SqlCommand
            cmd.Connection = cnn
            cmd.CommandText = "select ProductName,Price from Store order by Serial Desc"
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(DsProducts, "Store")
         
    
        End Sub
    

    and when I click the button I filter based on the product name which will be written in Textbox1 to retrieve the price in Textbox2.  the code is :

     Try
    
                Dim dv As DataView = New DataView(DsProducts.Tables("Store"))
                dv.RowFilter = "ProductName='" & TextBox1.Text & "'"
                TextBox2.Text = dv.Item(0).Item("Price")
    
            Catch ex As Exception
    
    
            End Try
    from what I heard is that I have to use Cache in order to use the code in ASP.net.  the question is how to convert it to ASP.net VB?

    regards

    • Moved by Carl Cai Wednesday, July 16, 2014 3:27 AM ASP.Net forum is more dedicated(from vb)
    Monday, July 7, 2014 5:30 AM

Answers

  • You can ask questions about ASP.Net in one of the ASP.Net Forums but you don't mention anything about what your code is for.

    Although I don't really know anything about ASP.Net.

    You say your moving from Windows Forms to ASP.Net. I suppose there's such a thing as an ASP.Net client and for now assume that would be what your code would be used in. But perhaps your code should be used in a Windows Form if all your trying to do is access a database or something from a webserver. I'm not really sure.

    Perhaps before you post a question in an appropriate ASP.Net forum you could perhaps describe, regardless of your code, what you want your app to do. With regard to how it is supposed to get information and from where also.

    After that I would guess you would receive appropriate replies on what to do including whether or not to post your question somewhere else.

    And please provide information that describes entirely the scenario and not some information that doesn't contain enough information for anybody reading your post to know what they need to know.


    La vida loca



    • Edited by Mr. Monkeyboy Monday, July 7, 2014 6:02 AM
    • Proposed as answer by Carl Cai Wednesday, July 16, 2014 3:27 AM
    • Marked as answer by Just Karl Wednesday, July 23, 2014 8:29 PM
    Monday, July 7, 2014 5:58 AM
  • Your difference is not VB.Net to ASP.Net but from Windows Forms to Web Forms. 

    There is beside the used controls a big difference between those. An application made for the desktop clients is a single user client application. An application made for the Web is a multi user client application. 

    Desktop clients have so called state. The data is preserved for the client. An Asp.Net application has no state, at every post the data is released. 

    There are four solutions for that, but mostly is the most effective is the session in which data can be preserved inside IIS.

    For the rest there is not more difference between a windows forms application and a web forms application. Be aware it becomes something different if you start using inline VB code like by most is done who are visitors of the ASP.Net forums.

    The session 

    http://msdn.microsoft.com/en-us/library/System.Web.SessionState(v=vs.110).aspx

     


    Success
    Cor

    • Proposed as answer by Carl Cai Wednesday, July 16, 2014 3:27 AM
    • Marked as answer by Just Karl Wednesday, July 23, 2014 8:29 PM
    Monday, July 7, 2014 6:04 AM

All replies

  • You can ask questions about ASP.Net in one of the ASP.Net Forums but you don't mention anything about what your code is for.

    Although I don't really know anything about ASP.Net.

    You say your moving from Windows Forms to ASP.Net. I suppose there's such a thing as an ASP.Net client and for now assume that would be what your code would be used in. But perhaps your code should be used in a Windows Form if all your trying to do is access a database or something from a webserver. I'm not really sure.

    Perhaps before you post a question in an appropriate ASP.Net forum you could perhaps describe, regardless of your code, what you want your app to do. With regard to how it is supposed to get information and from where also.

    After that I would guess you would receive appropriate replies on what to do including whether or not to post your question somewhere else.

    And please provide information that describes entirely the scenario and not some information that doesn't contain enough information for anybody reading your post to know what they need to know.


    La vida loca



    • Edited by Mr. Monkeyboy Monday, July 7, 2014 6:02 AM
    • Proposed as answer by Carl Cai Wednesday, July 16, 2014 3:27 AM
    • Marked as answer by Just Karl Wednesday, July 23, 2014 8:29 PM
    Monday, July 7, 2014 5:58 AM
  • Your difference is not VB.Net to ASP.Net but from Windows Forms to Web Forms. 

    There is beside the used controls a big difference between those. An application made for the desktop clients is a single user client application. An application made for the Web is a multi user client application. 

    Desktop clients have so called state. The data is preserved for the client. An Asp.Net application has no state, at every post the data is released. 

    There are four solutions for that, but mostly is the most effective is the session in which data can be preserved inside IIS.

    For the rest there is not more difference between a windows forms application and a web forms application. Be aware it becomes something different if you start using inline VB code like by most is done who are visitors of the ASP.Net forums.

    The session 

    http://msdn.microsoft.com/en-us/library/System.Web.SessionState(v=vs.110).aspx

     


    Success
    Cor

    • Proposed as answer by Carl Cai Wednesday, July 16, 2014 3:27 AM
    • Marked as answer by Just Karl Wednesday, July 23, 2014 8:29 PM
    Monday, July 7, 2014 6:04 AM