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
 Database Manipulations in a Class File
Posted by Swetha Hjii on  8/11/2008 12:17:41 PM Category: Asp.Net 2.0
Add to my favorites
Email to friend
Hi,

Can anyone let me know how to create a database connection in a class file?


Post Your Reply Post New Question

 Viewer's Reply
SqlConnection in Class File
Answered By Moderator1 on 8/16/2008 2:35:13 AM
In your class file,

Using System.Data.SqlClient;


public SqlConnection myconn;

public void OpenConnection()
{
myconn=new SqlConnection("Your Connection String");
myconn.Open();
}

public void CloseConnection()
{
myconn.Close();
}

Create an instance to your class file. then you can access the myconn object.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Integrating Silverlight 4 with SharePoint 2010 - Free 42 Page Sample Chapter
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
Speech Technology Magazine