Skip to content

ADO.NET

Neiluffer Shama

Asked Mar 29, 2013, 9:10 AM EDT1 answer
Share
LinkedInX
I have a table tbl_ModelNo
in that it has feilds: ModelNoId, ModelNo, Narration.
The values are inserted and shown in a data grid view.
While inserting values in tbl_ModelNo
if the same ModelNo inserted as that in the grid view it should not be inserted and it must show a message that THIS MODEL No already exist.How to write code for this in c#

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    in your insert sp first check for Model No not exists like following

    if  exists(select * from tbl_ModelNo where ModelNo=@ModelNo)
    Begin
            Set @outputParamer='Model Number Already Exists'
            return
    End

    -- Here write your Insert Query
    0