Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] How can i make a database connection?

Newbie Spellweaver
Joined
Dec 6, 2010
Messages
31
Reaction score
10
Hello guys, im really bad right now. I can't get my GUI connect to my extern Database. Its hosted on my own host, so how can i make a connection to the host, + a QUERY? Like if it connects, that it makes the Query what ive put in the textbox1?
Example:
Console.Command = "" + textbox1.text + "";
or
Console.Command = (textbox1.Text);
or something else, +
in the textbox i did write example: "SELECT pixels FROM users WHERE id = 1;"

Thanks in advance :p
 
Custom Title Activated
Loyal Member
Joined
Nov 27, 2009
Messages
1,905
Reaction score
948
Hello guys, im really bad right now. I can't get my GUI connect to my extern Database. Its hosted on my own host, so how can i make a connection to the host, + a QUERY? Like if it connects, that it makes the Query what ive put in the textbox1?
Example:
Console.Command = "" + textbox1.text + "";
or
Console.Command = (textbox1.Text);
or something else, +
in the textbox i did write example: "SELECT pixels FROM users WHERE id = 1;"

Thanks in advance :p
read this article

helped me out a lot :p

just get the connecter (MySql.Data.dll) + add it to references then just copy the code and modify it to your needs
Console.writeLine("HOST");
string host = Console.readLine();
Console.writeLine("USER");
string user = Console.readLine();
Console.writeLine("PASS");
string pass = Console.readLine();
Console.writeLine("DB");
string db = Console.readLine();
string conString = "server=" + host + ";userid=" + user + ";password=" + pass + ";database=" + db + "";
 
Last edited:
WHOOOOOO
Loyal Member
Joined
May 21, 2008
Messages
960
Reaction score
47
Moved to coder's paradise. Reckon you can get more help here. Good luck!
 
It won't fit
Loyal Member
Joined
May 18, 2007
Messages
1,789
Reaction score
291
read this article

helped me out a lot :p

just get the connecter (MySql.Data.dll) + add it to references then just copy the code and modify it to your needs
Console.writeLine("HOST");
string host = Console.readLine();
Console.writeLine("USER");
string user = Console.readLine();
Console.writeLine("PASS");
string pass = Console.readLine();
Console.writeLine("DB");
string db = Console.readLine();
string conString = "server=" + host + ";userid=" + user + ";password=" + pass + ";database=" + db + "";


You don't even need the connector installed. You just need that file. I used it recently without connector installed and it still worked the same way. :)

Just a tid bit
 
Joined
Jan 27, 2007
Messages
1,201
Reaction score
1,067
Not trying to be rude or anything but you could have googled mySQL in c#, there are tons of results to do with mySQL in .NET languages.

@Abysmal That's because the DLL imports the mySQL class into your project as service reference that way you don't have to use the connector. It's better for people who know what their doing, the connector pools connections for you automatically but using the DLL you have to do it yourself, if you want optimal performance.
 
Experienced Elementalist
Joined
Apr 12, 2009
Messages
241
Reaction score
32
fyi, you can use linq-to-sql... just drag and drop tables into the designer... and you can access your code like

int? user_id = Users.Where(x=>x.UserName=="Jim" && x.Password=="coolpw").Select(x=>x.UserID).SingleOrDefault();
 
Experienced Elementalist
Joined
Apr 12, 2009
Messages
241
Reaction score
32
*ahem*.

Garbage COLLECTED .net language, you mean ;) hehe
 
Custom Title Activated
Loyal Member
Joined
Apr 8, 2008
Messages
1,125
Reaction score
330
... Or you can make your own little databases VIA data sources.
 
Back
Top