473,378 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to find whether particular value is present in database

11
hi..
i hav created a form which gets empid as input and retrieve data from database and display information about employee.now wen i get empid as input i should check with d table tat empid shold exist. if does not exist i should display a message..
can anyone suggest me d code or idea how can i do it.
Feb 5 '09 #1
8 5100
ck9663
2,878 Expert 2GB
Sounds like an assignment. What do you have so far?

-- CK
Feb 5 '09 #2
srig
11
i hav done for inserting,deleting,updatin,displayin..
now i hav to validate

thanks & regards
Sri
Feb 6 '09 #3
ck9663
2,878 Expert 2GB
Could you post what you have so far?

-- CK
Feb 13 '09 #4
srig
11
i hav created forms for insertin emp detail,deletin,updatin and viewing..wen i insert i need to check whether the id i am giving exist already in a database or not.. if exist i should display an error mess..
u need the code of front end wat i hav done or the database..im sorry i don get u whether i should post my entire code or not.

thanks
sri
Feb 13 '09 #5
ck9663
2,878 Expert 2GB
Use Search Condition


-- CK
Feb 14 '09 #6
OuTCasT
374 256MB
Expand|Select|Wrap|Line Numbers
  1. Private Function ValidateEmployeeID(ByVal EmployeeCode As String) As Boolean
  2.         Dim sqlCon As SqlConnection = Nothing
  3.         Dim sqlCom As SqlCommand = Nothing
  4.         Dim lookupID As String
  5.  
  6.         lookupID = Nothing
  7.  
  8.         'Check for EmployeeCode
  9.         If ((EmployeeCode Is Nothing)) Then
  10.             MsgBox("[ValidateEmployeeID] Input Validation of EmployeeID Failed", MsgBoxStyle.Critical)
  11.             Return False
  12.         End If
  13.         Try
  14.             sqlCon = New SqlConnection("Data Source=./SQLEXPRESS;Initial Catalog=<DBNAME>;Integrated Security=True")
  15.             sqlCon.Open()
  16.  
  17.             'Create sqlCommand to retrieve EmployeeId
  18.             sqlCom = New SqlCommand("select [employeeId] from EmployeeDetails where [employeeid]=@EmployeeID COLLATE SQL_Latin1_General_CP1_CI_AS", sqlCon)
  19.             sqlCom.Parameters.Add("@EmployeeID", SqlDbType.VarChar, 25)
  20.             sqlCom.Parameters("@EmployeeID").Value = txtEmployeeCode.Text
  21.  
  22.             lookupID = sqlCom.ExecuteScalar
  23.  
  24.             sqlCom.Dispose()
  25.             sqlCon.Dispose()
  26.         Catch ex As Exception
  27.             sqlCom.Dispose()
  28.             sqlCon.Dispose()
  29.             MsgBox("Employee ID Already Exists Please make another selection", MsgBoxStyle.Information)
  30.         End Try
  31.         If (lookupID Is Nothing) Then
  32.             Return False
  33.         End If
  34.         Return (String.Compare(lookupID.ToUpper, txtEmployeeCode.Text.ToUpper, False) = 0)
  35.     End Function
Feb 16 '09 #7
' will not work
' If ((EmployeeCode Is Nothing)) Then
' MsgBox("[ValidateEmployeeID] Input Validation of EmployeeID Failed", MsgBoxStyle.Critical)
' Return False
' End If
' this will fire!
If IsNull(EmployeeCode) Then
MsgBox("[ValidateEmployeeID] Input Validation of EmployeeID Failed", MsgBoxStyle.Critical)
Return False
End If
Feb 17 '09 #8
OuTCasT
374 256MB
@Gradwohl
This is not really needed actually.
Feb 17 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Adam Hearn | last post by:
Sorry if this difficult to understand but I'm pulling my hair out and could do with some good ideas please... I've developed an application which in .NET as a Windows service which is simply...
1
by: rahman | last post by:
I know it should be very easy but I am new in ASP so I could not figured out. Here is the simplified version of my code: thePaymentID= request.querystring("IDValue") SQLqueryPayment= "SELECT...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
6
by: rcamarda | last post by:
Hello, I need to find students that have 4 consecutive absences. When a student is absent 4 times in a row, they can be dropped from the class. My class attendance file contains each attendance...
2
by: priya_sreejith | last post by:
how can we find whether a particular SQL recordset is present or not using VB ?
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
1
by: kraj123 | last post by:
Hi, How to Find ,if already a environment variable is set in hash table in perl. Actually i want to check if a environmental variable in perl script, which is present in oracle database has...
0
by: akaley | last post by:
Hi Every one, i have a small requiremnet.. My requirement is..As part of my application Excel Download functionality is there. At present the user down load the valuesi nto Excel file. But now...
0
natalie99
by: natalie99 | last post by:
Hey people! Being so lacking in access knowhow I have turned to good old 'asking the smart people' again! I need to create a query or lookup table (although I have had zero success with lookups...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.