Home
|
Articles
|
Namespace
|
Interview Questions
|
Tools
|
Jobs
|
Projects
|
Community
»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
Forums
»
ASP.NET Forums»
Checking if the data is already exist in the database
I have to check if the data is already exist in the database before inseting the new data. I have tried to check if the name is already exist or not but i got an error.so please can you help? CountryBLL.getCountryByCountryName(countryName).Rows(0).IsNull(0)
Checking to see if data already exists in database table
I am assuming you allow the user to enter a country name in a text box. Then you need to check a database table that contains a column that includes all of the country names entered thus far. You can get the value entered by the user then loop through the database table and compare the text box value to the row column value. If the values match you can exit the loop using the break statements and display a message to the user telling them that the country already exists in the database. Something like this. foreach(DataRow row in datatable) { if(textbox1.Text == row["country"].ToString()) { lblInfo.Text = "Record already exists in the database"; break; } }
© 2008 dotnetwatch.com --
Privacy policy
Website Design
&
Internet Marketing
by Shivam