How to findout the whether given is record is exists in table or not?

Posted by Iluvdotnetfunda under C# on 6/15/2012 | Points: 10 | Views : 1173 | Status : [Member] | Replies : 10
Hello Friends,

How to find whether the record is existed in the database or not.
Plzz help me.

Thanks




Responses

Posted by: Sheonarayan on: 6/15/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Read this article http://www.dotnetfunda.com/articles/article1590-how-to-check-for-the-existence-of-record-into-the-database.aspx

thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/18/2012 [Member] Silver | Points: 25

Up
0
Down
Also refer this
http://www.dmxzone.com/go?4615
http://forums.asp.net/t/1578461.aspx/1

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sowbud on: 6/20/2012 [Member] Starter | Points: 25

Up
0
Down
http://forums.asp.net/ is a good forum to learn about .NET . If you have any doubts you can directly go there.

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
IF EXISTS(SELECT * FROM TBL_Subscribers WHERE email = @adres)
BEGIN
--emaild exist, so write code accordingly
END
ELSE
BEGIN
--emaild does not exist, so write code accordingly
END

Regards
Muralidoss M

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnbhatt on: 7/8/2012 [Member] Starter | Points: 25

Up
0
Down
There are so many ways to do so.

Question is from where do you want to check?

Visual Studio Web Form, SSMS, or any other place. Please clear your question and reply.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 7/31/2012 [Member] Silver | Points: 25

Up
0
Down
please mark it as answer....That helps other who search the same...

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/31/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Refer this url.
http://www.java2s.com/Tutorial/Oracle/0040__Query-Select/EXISTSandNOTEXISTSVersusINandNOTIN.htm

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 1/24/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
While doing registration how we will know that a particular name is available to the user.

Program
Default.aspx code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
<asp:Button ID="Button1" runat="server" Text="Availability of name from the database"
BackColor="#FF99FF" Font-Bold="True" Width="329px" /><br />
<asp:Label ID="Labelcheck" Text="Please enter any name to be verified from the database" runat="server" BackColor="#FFFF99"
Width="197px" ForeColor="#FF3300"></asp:Label>
<asp:TextBox ID="txtUserName" runat="server" Width="197px"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUserName" ErrorMessage="*Name Required"></asp:RequiredFieldValidator>

<br />
<asp:Label ID="lblMessage" runat="server" BackColor="#FF3300"
ForeColor="Black"></asp:Label>
</form>
</body>
</html>

Default.aspx.vb code

Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim sqlda As SqlDataAdapter
Dim com As SqlCommand
Dim ds As DataSet
Dim str As String
Dim count As Integer
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
namecheck()
End Sub
Sub namecheck()
Dim con As New SqlConnection(strConnString)
con.Open()
str = "select count(*)from employee where ename='" & txtUserName.Text & "'"
com = New SqlCommand(str, con)
count = Convert.ToInt32(com.ExecuteScalar)
If count > 0 Then
lblMessage.Text = "Sorry! you can't take this username"
Else
lblMessage.Text = "You can take this username"
End If

End Sub


End Class


If this post helps you mark it as answer
Thanks

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundan64 on: 1/25/2013 [Member] Starter | Points: 25

Up
0
Down
Create query as: Select COUNT(*) from employee WHERE ename = ''yourvalue
and execute this query as ExecuteScalar.

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response