Hack Forums
[.NET] Selecting/Updating/Inserting MySQL - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Selecting/Updating/Inserting MySQL (/showthread.php?tid=5240831)



Selecting/Updating/Inserting MySQL - Netflix and Weed - Apr 17, 2016

Hello HackForums!

I am wondering if there is any good tutorials related to using MySQL with vb.net. Now I have seen plenty of them but they use php files for login/register/etc. However I do want to use a php file to connect to my database that way it's not stored in the application. If you know any tutorials or a good way of doing this it would help a lot thank you.


* - +Haze - Apr 17, 2016

In that case I would say learn PHP, understand how things work in PHP. Then learn how you can use PHP to create an API Endpoint that other devices can interact with.


* - Only3 - Apr 17, 2016

tut http://www.visual-basic-tutorials.com/Tutorials/MsCodes/code8.htm
cmd http://www.w3schools.com/sql


* - Zilog80 - Apr 17, 2016

Connect to MySQL from .NET using PHP? Really?
Maybe you need to connect it throught a wrapper coded in C++, and this C++ wrapper calls a VB5 wrapper and this one calls another COBOL app, and this finally call another wrapper coded in Delphi...[/ironic Mode off]

You only need the MySQL ".NET conector" available from dev.MySQL (http://dev.mysql.com/downloads/connector/net/) or the super-easy alternative: use NuGet Manager and simply use:

Install-Package MySql.Data

Once you have the MySql.Data reference into your project, all the CRUD operaciones are basically the same as SqlClient:
PHP Code

<?php 
Dim sqlConnection1 
As New SqlConnection("Your Connection String")
Dim cmd As New SqlCommand
Dim reader 
As SqlDataReader

cmd
.CommandText = "SELECT * FROM Customers"
cmd.CommandType = CommandType.Text
cmd
.Connection = sqlConnection1

sqlConnection1
.Open()

reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.

sqlConnection1.Close() 
Instead SqlConnection type you should have MySqlConnection type, instead SqlCommand you should have MySqlCommand, instead SqlDataReader you have MySqlDataReader,...


* - Netflix and Weed - Apr 17, 2016

(Apr 17, 2016 12:30 PM)+Haze Wrote:  In that case I would say learn PHP, understand how things work in PHP. Then learn how you can use PHP to create an API Endpoint that other devices can interact with.

I am very familiar with PHP. This would be just a huge process to go through just to do normal sql commands. As I do not wish to spend a week on a project it would just entirely be to much. Thank you though. :)

(Apr 17, 2016 12:59 PM)Only3 Wrote:  tut http://www.visual-basic-tutorials.com/Tutorials/MsCodes/code8.htm
cmd http://www.w3schools.com/sql

Thank you will check this out and hopefully it is what I need, Problem is that I know a good amount of vb.net and php but looking to make an sql based game. Thank you for the resources. :)

(Apr 17, 2016 01:06 PM)Zilog80 Wrote:  Connect to MySQL from .NET using PHP? Really?
Maybe you need to connect it throught a wrapper coded in C++, and this C++ wrapper calls a VB5 wrapper and this one calls another COBOL app, and this finally call another wrapper coded in Delphi...[/ironic Mode off]

You only need the MySQL ".NET conector" available from dev.MySQL (http://dev.mysql.com/downloads/connector/net/) or the super-easy alternative: use NuGet Manager and simply use:

Install-Package MySql.Data

Once you have the MySql.Data reference into your project, all the CRUD operaciones are basically the same as SqlClient:
PHP Code

<?php 
Dim sqlConnection1 
As New SqlConnection("Your Connection String")
Dim cmd As New SqlCommand
Dim reader 
As SqlDataReader

cmd
.CommandText = "SELECT * FROM Customers"
cmd.CommandType = CommandType.Text
cmd
.Connection = sqlConnection1

sqlConnection1
.Open()

reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.

sqlConnection1.Close() 
Instead SqlConnection type you should have MySqlConnection type, instead SqlCommand you should have MySqlCommand, instead SqlDataReader you have MySqlDataReader,...

Also thank you for your response and I was thinking about going with NuGet so if in my journey I don't find what I am looking for this is most likely what I will be using.




Again, I am trying to make a game in vb.net but it needs to store data is some type of database that can't be modified, Exception would be the developer so if there is any other methods you guys know to store data like this that would be great. :)