C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to store connectionstring in a class using C#


Posted Date: 31 Dec 2007    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: Shylaja       Member Level: Silver
Rating:     Points: 10



connection string in a class



//Connection class

using System.Data.OleDb;

public class Class1
{
public void connect(OleDbConnection con)
{
string str = "provider=sqloledb;database=sample;uid=sa;pwd=xxx;";
if(con.State == ConnectionState.Closed)
{
con.ConnectionString = str;
con.Open();
}
}
}



Here a aspx page using that connection class



public partial class _Default : System.Web.UI.Page
{
Class1 obj = new Class1();
}

private void rptrJobfairbind()
{
string sql = "select JobfairName from JobfairPostings";
OleDbConnection con = new OleDbConnection();
obj.connect(con);
OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);

rptrJfaircategory.DataSource = ds;
rptrJfaircategory.DataBind();
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using  .  Store connectionstring  .  Class  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: FindByText in ASP.NET
Previous Resource: To Split Delimiter
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

audio conferencing services

Contact Us    Privacy Policy    Terms Of Use