Question How to display message

yvette

New member
Joined
Nov 2, 2010
Messages
2
Programming Experience
Beginner
Hi, i'm new to vb.net.

i have a question.

Dim myCommand As New SqlCommand(strSQL, myConn)
myConn.Open()
Dim myRead As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.Default)

myRead.Close()

Catch exc1 As Exception
Response.Write(exc1.Message)
Finally
If Not (myConn Is Nothing) Then
If myConn.State = System.Data.ConnectionState.Open Then myConn.Close()
End If

How can i add a message like "Record Save" in a label???

And i want clear all information that i enter when the message "Record Save" is display.

Thanks
 
What you could do is register a javascript function to alert the user that the record has been saved, which would mean you'll need to set the body's onLoad attribute.

Or you could have a Label on the page, set to be invisible and upon successful save, just show that label.
 
First of, i hope you don't expect to insert data into database using SqlDataReader Class (System.Data.SqlClient).
If you want to display a message like "Record Saved" in a label just add a new label to the page and name it e.g. AlertLabel <asp:Label runat="server" id="AlertLabel" />

Then if insert command is successful just set its ForeColor and Text properties respectively e.g.
VB.NET:
' success
AlertLabel.ForeColor = Drawin.Color.Green
AlertLabel.Text = "Record Saved"
' failure
AlertLabel.ForeColor = Drawin.Color.Red
AlertLabel.Text = "Error Message Here"
 
Back
Top