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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyanarayan BajoriaPosted Jun 29, 2008, 8:20 AM
class Connection
{
SslConnection con=new SqlConnection("user id=sa;password=;datasource=");
con.Open();
}
Therese PunoPosted Jun 27, 2008, 8:19 AM
Hi..Friend..
Thank you very much...the code sample now its really work..
Thank you..
Dinusha GamagePosted Jun 26, 2008, 11:51 PM
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 !!! ~
Jan MontanoPosted Jun 26, 2008, 8:30 PM
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.