How to Check if the record exist in my table? RRS feed

  • Question

  • User273232671 posted

    hello everybody..

    I am trying to create a code to add to my web form where it checks into my sql table if the records exists in the table through an error msg or a message box, other wise continue with my already written code, I will be getting the entry that I want to check from a text box, an example of what I need is the follow:

    if ( Select * from MyTable where  EntryID =  TxtBox1.Text)

    exist then

    messagebox "record already exist"


    continue the code here

    But I don't know how to phrase it in C#, any idea?

    Wednesday, January 27, 2016 11:44 AM


  • User-219423983 posted

    Hi MishMish,

    If you want to implement your need using C#, you should use the following code


    If VB.Net, it should be DataSet.Tables(0).Rows.Count()

    But, you should know that, the “DataSet” should be an instance of class “DataSet”.

    Besides, you should make sure the instance of “DataSet” has the right result. There’s an example that you could have a look.


    Best Regards,

    Weibo Zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 28, 2016 1:47 AM

All replies