Question show Lable text = SQL Procedure Print message

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)
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
 
Your SqlConnection object has an InfoMessage event that you can handle and it will be raised when ever your procedure executes a PRINT statement, e.g.
Private Sub ExecuteProcedure(procedureName As String)
    Using connection As New SqlConnection("connection string here"),
          command As New SqlCommand(procedureName, connection)
        command.CommandType = CommandType.StoredProcedure

        AddHandler connection.InfoMessage, AddressOf SqlConnection_InfoMessage

        connection.Open()
        command.ExecuteNonQuery()

        RemoveHandler connection.InfoMessage, AddressOf SqlConnection_InfoMessage
    End Using
End Sub

Private Sub SqlConnection_InfoMessage(sender As Object, e As SqlInfoMessageEventArgs)
    MessageBox.Show(e.Message)
End Sub
 
hi,

Your code is good.. but my sql procedure run correct.. only problem in SQL procedure massage is not comming in .net lable text..

Please correct below code only for me..
da.Fill(ds, "KK")
Me.Lbl_Error.Visible =
False
Me.Lbl_Successful.Visible =
True
Me.Lbl_Successful.Text = ds.Tables("0").Rows(1)(1).ToString


i think.. problm is in this code only.
 
Now i have made changes in my sql procedure with output parameter...
ALTER procedure [dbo].[SP_UserAdd]

--Pass the Argument for Stored Procedure
@UserID nvarchar(50),
@UserPassword nvarchar(50),
@UserType nvarchar(50),
@UserFullName nvarchar(50),
@Final_Result varchar (100) = null output
AS
--Declare the Variable for Stored Procedure
declare @UserID_Check_Dup as nvarchar(50)
begin
set @UserID_Check_Dup = (select UserID from TblMUser where UserID = @UserID)
if @UserID_Check_Dup = @UserID
Begin
--Print N'This user is already in database'
--set @Final_Result = null
set @Final_Result = 'This user is already in database'
End
else
Begin
--Add new UserID
insert into TblMUser(UserID,UserPassword,UserType,UserFullName)
values(@UserID,@UserPassword,@UserType,@UserFullName)
--set @Final_Result = null
set @Final_Result = 'User has been created successfully'
--Print N'User has been created successfully'
--return ('User has been created successfully')
End
select @Final_Result as FinalResult
return
end


Now i want to print in vb.net lable text from above @Final_Result (SQL proc) variable...
My VB.net code is below.. Please make changes in this below code

Protected Sub Btn_CreateUser_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_CreateUser.Click
Try
Me.Lbl_Error.Text = ""
Me.Lbl_Successful.Text = ""
Me.Lbl_Error.Visible = False
Me.Lbl_Successful.Visible = False
If Trim(Txt_UserID.Text) <> "" And Trim(Txt_UserPassword.Text) <> "" And Trim(DD_UserType.Text) <> "--Select--" And Trim(Txt_UserFullName.Text) <> "" Then
objConn = New SqlConnection
objConn.ConnectionString = strConnString
objConn.Open()
Const SQL As String = "SP_UserAdd"
Dim cmd As New SqlCommand(SQL, objConn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue(
"@UserID", Trim(Txt_UserID.Text))
cmd.Parameters.AddWithValue(
"@UserPassword", Trim(Txt_UserPassword.Text))
cmd.Parameters.AddWithValue(
"@UserType", Trim(DD_UserType.Text))
cmd.Parameters.AddWithValue(
"@UserFullName", Trim(Txt_UserFullName.Text))
cmd.ExecuteNonQuery()
Me.Lbl_Successful.Visible = True
Me.Lbl_Successful.Text = ""
Else
Me.Lbl_Successful.Visible = False
Me.Lbl_Error.Visible = True
Me.Lbl_Error.Text = "Please select all mandatory fields"
End If
Catch ex As Exception
Me.Lbl_Successful.Visible = False
Me.Lbl_Error.Visible = True
Me.Lbl_Error.Text = ex.Message
End Try
End Sub

 
Back
Top