//Connection String with Server, Database, User and Password string connection_string = "SERVER=127.0.0.1;DATABASE=test;UID=*********;PASSWORD=********;PORT=3306"; //Set Connection configs MySqlConnection connection = new MySqlConnection(connection_string); try { //Open Connection connection.Open(); textbox1.AppendText("Connected Server: localhost. \nConnected Database: test"); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * From persons"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { textbox1.AppendText("\n\n"+reader["text"].ToString()); } reader.Close(); connection.Close(); } catch (Exception ex) { textbox1.AppendText(ex.Message); }
<?php $con = mysql_connect("localhost","*******","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $result = mysql_query("SELECT * FROM personen"); $row = mysql_fetch_array($result); echo "<pre>"; var_dump($row); mysql_close($con); ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)