Results 1 to 4 of 4

Thread: show a message?

  1. #1
    ntomer is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Jul 2012
    Posts
    2
    Reputation
    0

    show a message?

    Hi,

    I am a newbie in VB .Net though I've considerable experience in Java/J2EE. Due to some urgent I've to make a change in an existing ASP .Net application. i have to add a link, which will lead to a page, which will have a button. On this button's click, a stored procedure will be executed.

    I've been successful in adding the page, adding a button and calling the stored procedure. But I don't know how to pass the result of stored procedure to the user. Basically I want to show a message that records have been imported if no exception occurs; and an error message if an exception occurs.

    Please find my code below and suggest how can I do it -

    Code:
    <%@ Page Language="VB" MasterPageFile="~/Admin/AdminMain.master" AutoEventWireup="false"
        CodeFile="ImportData.aspx.vb" Inherits="Admin_ImportData" Title="Import Data" %>
    
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    
    
    <script runat="server">
        Protected Sub btnImportData_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim dtRecords As New DataTable
            
            Dim taSQL As New SqlDataAdapter
            
            Dim conStr As String = ConfigurationManager.ConnectionStrings("TOPWebConnectionString").ConnectionString
            Dim con As New SqlConnection(conStr)
            Dim command as SQLCommand = new SQLCommand("ImportData",con)
            
            try
                With command
                    .CommandType = CommandType.StoredProcedure
                    .Connection.Open()
                    .ExecuteNonQuery()
                    .Dispose()
                    .Connection.close()
                End With
            Catch ex as SQLException
                return
            End Try
        End Sub
    </script>
    
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <br />
        <br />
        <table width="100%" runat="server" cellspacing="0" cellpadding="4" bgcolor="#E8E8E8">
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnImportData" OnClick="btnImportData_Click" runat="server" Text="Import CSV files into database" />
                </td>
            </tr>
        </table>
    </asp:Content>
    Thanks

    Nitin

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,186
    Reputation
    2368
    You can for example add a Label control and set its Text property.

  3. #3
    ntomer is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Jul 2012
    Posts
    2
    Reputation
    0
    Quote Originally Posted by JohnH View Post
    You can for example add a Label control and set its Text property.
    Hi,

    I am an absolute newbie to VB .Net and don't know much about it. Can you please tell me exactly how can I do it in my code?

    Thanks and Regards

    Nitin

  4. #4
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,322
    Reputation
    959
    Quote Originally Posted by ntomer View Post
    Hi,

    I am an absolute newbie to VB .Net and don't know much about it. Can you please tell me exactly how can I do it in my code?

    Thanks and Regards

    Nitin
    Add an asp:label control to the aspx code then in your vb.net script code you set it's text property.
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking