.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

>>>Check duplicate while inserting record from Texbox.

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :ASP.Net
Hi, On inserting record, I want to check that for example if a user enters a telephone number for any record is already in the database then it should validate that the number already exists in table and you cannot enter a duplicate value. Then if user will provide some other telephone number then he allows to insert record. For insertion of record I used ObjectdataSource. User will enter telephone number in a simple textbox. I may want to inform that I am working in asp.net2.0 and also not allowed to use any third party control or ajaxtoolkit. Any idea would be appreciated.

View Complete Post

More Related Resource Links

Check Duplicate Record



I am facing a serious problem here.i developing  a college project and in admission page there are a field student_code(in database ) which is manually  auto generate but not  unique.so I use like following.

My student code procedure

Sub GetStudentCode()


        _dsABIT = eDataAccessLayer.DataAccess.GetResultSet(_strQuery, "CADMISSION")

        If _dsABIT.Tables(0).Rows.Count > 0 Then

            txtstudCode.Value = _dsABIT.Tables(0).Rows(0)("STMCODE")

        End If

    End Sub

So I call  this procedure after save procedure like

Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btnsubmit.Click

        If Page.IsValid Then



How to check if record is added in access database



I'm trying to put a registration page together in Visual Web Designer.

I would like to send a confirmation Email after someone is leaving his registration data and pressing the INSERT button.

The key fields in my database are: Email, Name, Surname, Address

Before I send the confirmation Email I would like to check if the email value entered in the form is realy added to the database.

Please for help in this matter. I was copy past already some C code in my page, therefore it will be fine if the code can be in C.

Again, I need help to:

- checking if record is realy added to database after pressing INSERT button

- setup the confirmation Email

Thank you in advance.


How can i check if record already exist in sql-server database ...

How can i check if record already exist in sql-server database ...

Formview check for duplicate value before insert

I've looked at some posts on here but I keep getting errors.  I am just trying to see if an email address exists already before the insert and if it does, have a label display that message to the user. From what I read so far, it looks like I could do a query in the ItemInserting event.  I just need help on the code.  Thanks in advance for any help.. Here is the Code Behind.....where I assume I can do the duplicate check in the ItemInserting event... Protected Sub duplicatecheck(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInsertingEnd   End Sub     Here is the formview page...   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="signup.aspx.vb" Inherits="signup" %> <! < <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></title>head>body>  <form id="form1" runat="server">  <div>      <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource2" Def

Check to see if record exists befor SQL Insert


I would like to check and see if a record exists before doing an insert. Here is the code I have tried:


Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Imports System.CodeDom
Imports System.Web
Imports System.Web.Security
Imports System.Web.Security.Roles
Imports System.Web.Security.Membership
Imports System.Security
Imports System.Security.Principal.WindowsIdentity

Partial Class template
    Inherits System.Web.UI.Page
    Private Shared prevPage As String = String.Empty

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If (Not IsPostBack) Then
            prevPage = Request.UrlReferrer.ToString()
        End If
    End Sub

    Protected Sub btn_Volunteer_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim IDProfileVolunteer As String = Session("IDProfileVolunteer")
        Dim IDProfileOrganization As String = CType(FormView1.FindControl("hf_IDProfileOrganization"), HiddenField).Value

        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim strconnection, strsqlinsert As String

        Dim currentUser As MembershipUser = Membership.GetUser()
        Dim currentUserId As Gu

how to check duplicate records in array c#



how to check duplicate records in array c#.

In my array list contain string[] arraylist = new Array[] { "First","Second","Third","First" };

what I want is return True or false ? (True = No duplicate, False= Duplicate entry)



How to check for exist word before inserting?


This is what I have at the moment.

insLusHmoobDataContext lusHmoobDC = new insLusHmoobDataContext();

lusHmoob lhbLusHmoob = new lusHmoob();

lhbLusHmoob.wordID = Guid.NewGuid();
lhbLusHmoob.word = txtWord.Text;
lhbLusHmoob.usage = txtUsage.Text;
lhbLusHmoob.hmgTrans = txtEnglishTrans.Text;
lhbLusHmoob.engTrans = txtEnglishTrans.Text;
lhbLusHmoob.originate = txtOriginate.Text;
lhbLusHmoob.modDate = Convert.ToDateTime(DateTime.Now.ToLongDateString());
lhbLusHmoob.insertDate = Convert.ToDateTime(DateTime.Now.ToLongDateString());

Is there a way to check if the word already exist in the database before the insert is commited? Can I somehow incoporated into this Insert or do I have to do my verification separately?

Check if record exists in mssql database c# code


Hello everyone!

I coded this page a while back, but I'm thinking there must be a better way to do this.  What I want to do is check real-time if various records exist in my database from a function in my C# code.  What I've done is added a sqldatabase onto my page, as well as a gridview.  Here is what I have done to verify if a record exists.

public bool RecordExists(string gName, DateTime gDate)
        // Set default to false
        bool returnBool = false;
        SqlDataSourceEvents.SelectCommand = "SELECT ID, StartTime, EndTime, EventName, UserID, Details FROM EventTable WHERE (DATEPART(day, StartTime) = DATEPART(day, '" + gDate.ToString() + "')) AND (UserID='" + gName + "')";

        for (int i = 0; i < GridViewEvents.Rows.Count; i++)
            if (DateTime.Parse(GridViewEvents.Rows[i].Cells[0].Text) == gDate)
                if (GridViewEvents.Rows[i].Cells[2].Text == gName)
                    returnBool = true;
        // Return SqlDataSourceEvents to original state
        SqlDataSourceEvents.SelectCommand = "SELECT ID, StartTime, EndTime, EventName, UserID, Details FROM EventTable WHERE (DATEPART(month, StartTime) = 

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

Check All with JQuery and a Asp.Net GridView

Display a Grid on the screen with a checkbox in each row. At the bottom of the page have "Check All" button.

Typically if I need to do anything interesting I use a template column. So my GridView will look like the one below (most other columns removed for readability). The only interesting point to note is the CssClass="ApprovalCheckBox" in the CheckBox ItemTemplate.

check box control


Hi ,

I have a three check box in my web form ,i need to choose only one check box, if i choose one check box

another 2 check box automatically unchecked

can i use jquery for check box

I thought this would be simple... Trying to create a login does an ajax check before submit


I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time

how to check a textbox value in jquery?



I want to perform some action when an asp.net textbox value length is greater than 1 character. And for this I wanted to know how to write this check in jquery?

I have created a check like below-

if ($('[id=txtUserInput]').val().length > 2)
{ do some work...} 

But its giving me the following error

$("[id=txtUserInput]").val() is undefined

Can anybody let me know the right way of doing this?



How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

Automatically redirect to HTTPS and check if SSL is active



I've set in the web.config:

    <!-- User Authentication -->
    <authentication mode="Forms">
      <forms loginUrl="~/Page/View/Content/Login.aspx" timeout="2880" requireSSL="true" />

This works fine. If there is no ssl connection, the login form doesn't continue. But I would like to check if ssl is active (in codebehind) and, if it's possible, to automatically the user to the https page if he's currently on http. (I could do this job by manually redirect with page.response("https://url.../login.aspx"); but this is not really generic. For example if the webapp is moved to another domain it doesn't work anymore... I'm looking for something like: FormsAuthentication.RedirectWithSSL(); or so... :D)


how to check which pages of my site that my visitor visiting at the moment


 Hi all, and thanks a lot for the replies since now. I have a new question :

I prepared a simple instant messaging system for my web site and i would like to learn which visitor (registered member) is at which page of my site. 

For example : 

Uid:10000, Username:donald, NameSurname:Donald DUCK is a registered and signed in visitor.

I need the code which tells me that visitor is at which page (ie. images.aspx?imageid=143223)

Sorry for my poor english, and let me know if i should explain more clearly :)

Have a good evening...

Tools for memory error check in VS2005


Dear all,

I am going to write vs2005 program with ASP.NET and C++.

As you know that C++ will involve a lot of memory error handling.

Do you know is there any tools for checking memory error in Code Behind C++??

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend