tAngel
Member
- Joined
- Jun 24, 2019
- Messages
- 7
- Programming Experience
- Beginner
hi!! im new here and begginer with C# (english too haha)
i'm trying to learn english because in brazil we do not have (good) forums that help with C# but anyway ...
here is my problem :
i want make one multitool administrative for Grand Chase private server, where you can change, update, delete user and "C, R, U, D" anything in database, i want make one class "Connection.cs" where i can Open and Close my connection whenever i want ...
i get only the first form, the second or third the connection does not open anymore!!
i would like to know a way to make a connection class that can be accessed by any form to open the connection whenever you need to execute a command in SQL, Thanks!
i really want to learn C# and i will not give up but have someone to make things a little easier sometimes it brings a great happiness, im 4 days trying and today i found this forum, thank you in advance for helping me.
i'm trying to learn english because in brazil we do not have (good) forums that help with C# but anyway ...
here is my problem :
i want make one multitool administrative for Grand Chase private server, where you can change, update, delete user and "C, R, U, D" anything in database, i want make one class "Connection.cs" where i can Open and Close my connection whenever i want ...
i get only the first form, the second or third the connection does not open anymore!!
C#:
public class Conexao // Conexao == Connection (br lang)
{
public string Data; //Used to get TextBox values with Data, user and Pass to sqlserver
public string User;
public string Pass;
SqlConnection con = new SqlConnection();
public void receber(string data, string user, string pass) //get textbox values to use here
{
this.Data = data; // my variable = textboxes value
this.User = user;
this.Pass = pass;
}
public Conexao() // Conexao == Connection (br lang)
{
con.ConnectionString = (@"Data Source=" + Data + ";Initial Catalog=testeDB;Persist Security Info=True;User ID=" + User + ";Password=" + Pass + ";");
//con.ConnectionString = (@"Data Source=ANGEL-PC\SQLRGZ;Initial Catalog=testeDB;Persist Security Info=True;User ID=sa;Password=angel123");
}
public SqlConnection conectar() //conectar == connecting (br lang)
{
if (con.State == System.Data.ConnectionState.Closed)
{
con.ConnectionString = (@"Data Source=" + Data + ";Initial Catalog=testeDB;Persist Security Info=True;User ID=" + User + ";Password=" + Pass + ";");
con.Open();
}
else
{
con.Close();
}
return con;
}
i would like to know a way to make a connection class that can be accessed by any form to open the connection whenever you need to execute a command in SQL, Thanks!
i really want to learn C# and i will not give up but have someone to make things a little easier sometimes it brings a great happiness, im 4 days trying and today i found this forum, thank you in advance for helping me.