Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Check whether a specific value exists
Author:
Vimal Lakhera
E-mail:
Click to e-mail author
Website:
http://geocities.com/vimallakhera
Submitted:
9/17/2005
Version:
ASP.NET 1.1
Compatibility:
ASP.NET 1.0, ASP.NET 1.1
Category:
Databases
Views:
8498
Check whether a specific value exists. Code is in C#. ///
/// This function is used to check whether a specific value exist or not in a database /// Or It check for Duplicate values ///
///
FieldName of Table ///
Table Name ///
Field Value to be checked ///
Boolean value i.e True if value already exist,False if value doesn't exist
Declarations:
'none
Code:
public bool checkValueExists(string strField,string strTable,string strFieldValue) { try { StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("select Count("+ strField +") from "+ strTable +" where "+ strField +" = '"); sbQuery.Append(strFieldValue.Replace("'","''")); sbQuery.Append("'"); if(ExecScaler((sbQuery.ToString()))>0) return true; } catch(Exception ex) { throw new Exception(ex.ToString()); } return false; }
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement