show a message?

ntomer

New member
Joined
Jul 24, 2012
Messages
2
Programming Experience
10+
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 -

VB.NET:
<%@ 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
 
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
Add an asp:label control to the aspx code then in your vb.net script code you set it's text property.
 
Back
Top