Avatar of Ed
EdFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Blurred text
THIS SOLUTION IS 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
Avatar of Ed
Ed
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Perfect, thanks
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo