Avatar of Ed
Ed
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Duplicate Validation in code(vb)

How can I check for a record that exists before insert in code behind.

eg

In the below I want to check that the @QUALSCHEMEID exist or not

 Public Sub InsertGCH()

            'If Session("ModeType") = "Insert" Then

            Dim strConnString As String = ConfigurationManager.ConnectionStrings("IrisConnectionString").ConnectionString

            Dim con As New SqlConnection(strConnString)

            Dim cmd As New SqlCommand()

            cmd.CommandType = CommandType.StoredProcedure

            cmd.CommandText = "Insert_REVIEWS_GCH"

            'cmd.Parameters.Add("@TRAINEEID", SqlDbType.NVarChar).Value = Request("TRAINEEID")

            'cmd.Parameters.Add("@POT", SqlDbType.Int).Value = Request("POT")

            cmd.Parameters.Add("@QUALSCHEMEID", SqlDbType.Int).Value = ddlQUALSCHEMEID.SelectedValue.Trim()

            cmd.Parameters.Add("@ReviewID", SqlDbType.Int).Value = Session("REVIEWS")

            cmd.Parameters.Add("@GCH", SqlDbType.NVarChar).Value = txtGCH.Text.Trim()


            cmd.Connection = con



            con.Open()

            cmd.ExecuteNonQuery()




            con.Close()

            con.Dispose()





        End Sub

Open in new window

ASP.NETVisual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Ed

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mlanda T

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ed

ASKER
Perfect, thanks
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy