Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[HELP] Configure database connection sa loob ng system - C#

NeoToxico22

Amateur
Advanced Member
Messages
140
Reaction score
0
Points
26
Mga master. Pahelp naman. Pano po ba pwedeng iconfigure yung mysql connection?
Yung pwede i-edit ni user yung server nung system. Kasi yung connection ko po nasa string lang.

Code:
public string connString = "datasource = localhost; port = 3306; database = dbname; username = root; password = 123;";

Yung pag-open sana po nung system, sa log in meron dun parang configure connection tapos dun na lang niya ieedit. Wala na po ako mahanap sa google. Sana may makatulong. Salamat
 
pwede yan. gumawa ka ng class mo na may public properties na datasource, port, databasename, username, password
tapos sa login page ipasa mo yung mga values na yan sa class mo para magagamit mo across your application

or gamit ka ng xml file dun mo isave configs mo :thumbsup:
 
Bale gawa ako ng public properties na datasource, port, databasename, username, password na galing sa textbox value, then may class na lang din ako kung san ilalagay ko yung mga properties na yan, tama ba sir?
 
public class DatabaseConnection
{
private string _datasource = "MySQL";

public string DataSource { get { return _datasource;} set {_datasource = value}}

}

class Main
{

DatabaseConnection databaseConn = new DatabaseConnection();
txtBox1.Text = databaseConn.DataSource;

}
 
Still need some help.
Gusto ko sana mag-save yung setting nung user base sa workstation, yung kahit irestart yung system naka-save pa rin yung server nya.
 
"You want to use an App.Config.

When you add a new item to a project there is something called Applications Configuration file. Add that.

Then you add keys in the configuration/appsettings section

Like:
<configuration>
<appSettings>
<add key="MyKey" value="false"/>

Access the members by doing
System.Configuration.ConfigurationSettings.AppSettings["MyKey"];

This works in .net 2 and above.
" - extracted from http://stackoverflow.com/questions/...n-file-in-a-windows-forms-c-sharp-application
 
Back
Top Bottom