Hack Forums
[.NET] Duplicate Data Gridview - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Duplicate Data Gridview (/showthread.php?tid=5076670)



Duplicate Data Gridview - TheGreat1 - Nov 30, 2015

Hi,

I have a grid view... Contact form.
How do I make it so users cannot use the same number to contact.

Contact number is stored in the database but if the users states the same number... the form shall not submit
I am using the InsertQuery on the SQLDataSource for the grid view.


* - nathan72389 - Nov 30, 2015

check it against what you already have before you add/ update anything.
this seems more of a logic question.


* - TheGreat1 - Nov 30, 2015

(Nov 30, 2015 07:52 AM)nathan72389 Wrote:  check it against what you already have before you add/ update anything.
this seems more of a logic question.

How do I come across to doing that


* - rageSpreed - Nov 30, 2015

(Nov 30, 2015 07:52 AM)nathan72389 Wrote:  check it against what you already have before you add/ update anything.
this seems more of a logic question.
Agree, maybe you can use a constraint on the db table if you dont want to code it in you app.
But you will need to check the output of the instert because of contraint exception


* - nathan72389 - Nov 30, 2015

(Nov 30, 2015 07:53 AM)TheGreat1 Wrote:  How do I come across to doing that

what!
if "A" = "B" then do "C" else do "D"


* - TheGreat1 - Nov 30, 2015

(Nov 30, 2015 07:55 AM)nathan72389 Wrote:  what!
if "A" = "B" then do "C" else do "D"

No shit dude but I'm stuck on 'How to find out if it exist in the table' rather than completing the statement


* - +Haze - Nov 30, 2015

Code
Private Sub btnSubmitForm_Click(obj, e)
  If DataAccessInstance.IsNumberExists(txtPhoneNumber.Text)
    
  Else

  End If
End Sub

Then inside your IsNumberExists Method

SELECT number FROM tableName WHERE number = @number

Check the row count. Return that as a boolean result.


Done