Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Write a query with two count conditions

$
0
0

Hi Guys!

In my VB.Net form I have NameBox and a SurnameBox and they are writing the data to the related columns in my sql server 2012 database with a Save button.

So how can I write something to the buttonclick event like:

If NameBox.Text & " " & SurnameBox.Text = Contacts_Table Name_Colum & " " & Contacts_Table Surname_Colum(for the same row) Then

Messagebox.Show("A person with the same name and surname already exist!")

End If

or

Count of Contacts_Table Name_Colum & " " & Contacts_Table Surname_Colum for the same line(row) returns 1 or more results for the string NameBox.Text & " " & SurnameBox.Text, then, show the warning.

In many places, they say it can be achieved by writing a query. How can I write this? Any example? Also I read something like VLookUp. How can I use this? Or does it have nothing to do with my question?

I am sorry for my bad English. I hope, I was able to define what I need.

Thanks a lot!




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>