Hillo,
Since im new in C#.net will you please help me..
i want to put my database connection to a class..
but isnt work..please help me..
thanks.
Hillo,
Since im new in C#.net will you please help me..
i want to put my database connection to a class..
but isnt work..please help me..
thanks.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jan MontanoRank #1,295 · 1.3K reputationPosted Jun 26, 2008, 4:30 PM EDT
please post what you have so far. pls post the code that isn't working and what result you expect to achieve with the code. thanks.
Dinusha Gamage67 reputationPosted Jun 26, 2008, 7:51 PM EDT
Hi Friend,
The given below coding is used to create the DB connection class. I think you know how to get the connectionstring .
// This should be created in a namesapce
public class Connection
{
public string SetConnection()
{
string connectionstring = "Data Source=LOCALSERVER;Initial Catalog=ACME_ERP;Integrated Security=True";
return connectionstring;
}
}
After that you can create a object from that class and call the SetConnection() method as given below:
public
Connection conObject = new Connection();SqlConnection
scon = new SqlConnection(conObject.SetConnection());Does that do what you want?
~ Happy Coding !!! ~
Therese Puno15 reputationPosted Jun 27, 2008, 4:19 AM EDT
Hi..Friend..
Thank you very much...the code sample now its really work..
Thank you..
Satyanarayan Bajoria12 reputationPosted Jun 29, 2008, 4:20 AM EDT
class Connection
{
SslConnection con=new SqlConnection("user id=sa;password=;datasource=");
con.Open();
}