Krishnaoptif
New member
- Joined
- May 24, 2012
- Messages
- 3
- Programming Experience
- 1-3
Hi,
I want to store a print msg in vb.net lable text..
my stored procedure is (it works fine)
my VB.net code for click Event. actually procedure is runing fine.. and data is storing in DB but i want to show my stored procedure input message in my VB.net labl.text.....
Please help any one because i am new in this vb.net..
Regards,
Krishna
9560305552
I want to store a print msg in vb.net lable text..
my stored procedure is (it works fine)
VB.NET:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ANSI_NULLS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ON
set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]QUOTED_IDENTIFIER[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ON
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]go
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ALTER[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]procedure[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [dbo][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000][SP_UserAdd][/COLOR]
[COLOR=#000000][/COLOR]
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]--Pass the Argument for Stored Procedure
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserID [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]50[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserPassword [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]50[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserType [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]50[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserFullName [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]50[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]AS
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]--Declare the Variable for Stored Procedure
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @UserID_Check_Dup [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]as[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]50[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]begin
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @UserID_Check_Dup [/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]select[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] UserID [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]from[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TblMUser [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]where[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] UserID [/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @UserID[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @UserID_Check_Dup [/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @UserID
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Begin
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Print[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] N[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'This user is already in database'
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Begin
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]--Add new UserID
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]insert[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]into[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TblMUser[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]UserID[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]UserPassword[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]UserType[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]UserFullName[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]values[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserID[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserPassword[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserType[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@UserFullName[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Print[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] N[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'User has been created successfully'
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]end
[/COLOR][/SIZE][/COLOR][/SIZE]
my VB.net code for click Event. actually procedure is runing fine.. and data is storing in DB but i want to show my stored procedure input message in my VB.net labl.text.....
VB.NET:
[SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Btn_CreateUser_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Btn_CreateUser.Click
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Trim(Txt_UserID.Text) <> [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Trim(Txt_UserPassword.Text) <> [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Trim(DD_UserType.Text) <> [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"--Select--"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Trim(Txt_UserFullName.Text) <> [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]objConn = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SqlConnection
objConn.ConnectionString = strConnString
objConn.Open()
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ds [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DataSet = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DataSet()
strSQL = [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"exec SP_UserAdd '"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & Trim(Txt_UserID.Text) & [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"','"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & Trim(Txt_UserPassword.Text) & [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"','"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & Trim(DD_UserType.Text) & [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"','"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & Trim(Txt_UserFullName.Text) & [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"'"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]da = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SqlDataAdapter(strSQL, objConn)
da.Fill(ds, [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"KK"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Lbl_Error.Visible = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Lbl_Successful.Visible = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Lbl_Successful.Text = ds.Tables([/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).Rows(1)(1).ToString
[/SIZE][SIZE=2][SIZE=2]Else
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]Me[/SIZE][/SIZE][SIZE=2].Lbl_Successful.Visible = [/SIZE][SIZE=2][SIZE=2]False
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]Me[/SIZE][/SIZE][SIZE=2].Lbl_Error.Visible = [/SIZE][SIZE=2][SIZE=2]True
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]Me[/SIZE][/SIZE][SIZE=2].Lbl_Error.Text = [/SIZE][SIZE=2][SIZE=2]"Please select all mandatory fields"
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]End[/SIZE][/SIZE][SIZE=2] [/SIZE][SIZE=2][SIZE=2]If
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Exception
[/SIZE][SIZE=2][SIZE=2]Me[/SIZE][/SIZE][SIZE=2].Lbl_Successful.Visible = [/SIZE][SIZE=2][SIZE=2]False
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]Me[/SIZE][/SIZE][SIZE=2].Lbl_Error.Visible = [/SIZE][SIZE=2][SIZE=2]True
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Lbl_Error.Text = ex.Message
[/SIZE][SIZE=2][SIZE=2]End[/SIZE][/SIZE][SIZE=2] [/SIZE][SIZE=2][SIZE=2]Try
[/SIZE][/SIZE][SIZE=2][/SIZE][SIZE=2][SIZE=2]End[/SIZE][/SIZE][SIZE=2] [/SIZE][SIZE=2][SIZE=2]Sub
[/SIZE][/SIZE]
Please help any one because i am new in this vb.net..
Regards,
Krishna
9560305552