Support Forums

Full Version: [C#][VB.NET] MySQL Example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just a basic example for connecting to your online database. Shouldn't be hard to convert C# to VB.NET.

Code:
using MySql.Data.MySqlClient;

MySqlConnectionStringBuilder conString = new MySqlConnectionStringBuilder();
conString.Server = "server/host here";
conString.Database = "database here";
conString.UserID = "username here";
conString.Password = "password here";

MySqlConnection con = new MySqlConnection(conString.ToString());
MySqlCommand cmd = con.CreateCommand();

try
{
con.Open();
MessageBox.Show("Connected");
}
catch
{
MessageBox.Show("Cannot connect");
}
(07-01-2012, 05:46 PM)HF~Legend Wrote: [ -> ]Why not go post here : http://www.supportforums.net/forumdisplay.php?fid=20 ??

That's C++ and this is C#.
(07-01-2012, 06:37 PM)AceInfinity Wrote: [ -> ]That's C++ and this is C#.


Just for that ? Put a code (C#) in Visual basic... I'm crazy or ??
(07-02-2012, 09:14 AM)HF~Legend Wrote: [ -> ]Just for that ? Put a code (C#) in Visual basic... I'm crazy or ??

I don't know what you're trying to point out here....

You pointed towards a C++ forum, and now you're referencing C#/VB? Unsure

Yes C#/VB can be easily converted, but you can't put C# code directly into VB... Conversions still have to be made.
(07-02-2012, 09:14 AM)HF~Legend Wrote: [ -> ]Just for that ? Put a code (C#) in Visual basic... I'm crazy or ??

I do not see C# subforum around here, so why not post in here? It is part of the .NET Framework and it's not hard to convert C# to VB.NET

Blackhat
(07-02-2012, 06:00 PM)Mercury Wrote: [ -> ]I do not see C# subforum around here, so why not post in here? It is part of the .NET Framework and it's not hard to convert C# to VB.NET

Blackhat

Exactly, read the forum title: "Visual Basic and the .NET Framework"

VB & C# are traditionally Microsoft languages built around the .NET Framework. The other forum is specifically for C++ programming. And C++ doesn't have to be .NET.
Just a note if your connecting to a SQL database your better off just creating a httpwebrequest to a page and letting PHP handle the connection so your database information will be much safer
(07-19-2012, 09:38 AM)Sutton2k9 Wrote: [ -> ]Just a note if your connecting to a SQL database your better off just creating a httpwebrequest to a page and letting PHP handle the connection so your database information will be much safer

[Image: 678516f32180ecc8da2dc286bc4362af.png]

Converting code isnt that hard, i'll post a few links to converters once i get ten posts and this limit is removed