AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 insert, update,delete and fetch data from mssql2000 using class
Posted by naveed hussain on  5/7/2009 6:03:24 AM Category: VB.NET
Add to my favorites
Email to friend
I want to know that how to create database using class i used many tutorial but there is soming error to understand me ,so if you will send me video toturial or step by sep process to create this database so i will be very great full

Post Your Reply Post New Question

 Viewer's Reply
Re:Class File for insert,update,delete
Answered By Sreekumar on 5/28/2009 6:55:18 AM
Create a class file and copy this

public bool InsertUpdateDelete(string query)
{
SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString);
try
{
if (sqlcon.State == ConnectionState.Closed)
{
sqlcon.Open();
}
SqlCommand sqlcmd = new SqlCommand(query, sqlcon);
sqlcmd.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
if (sqlcon.State != ConnectionState.Closed)
{
sqlcon.Close();
}
}
}
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Easing the Migration to Microsoft SQL Server 2005
Website Magazine
The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition - Free 207 Page Preview!