Tuesday, May 11, 2021

Creating a LAMP stack on AWS Free Tier

 https://shawn-shi.medium.com/how-to-host-a-lamp-web-application-server-on-aws-ec2-for-free-8f6fc61463ed#:~:text=Its%20free%20tier%20allows%20everyone,PHP)%20automatically%20pre%2Dinstalled.

Creating a Table in MySQL and Inserting some data

 MySqlCommand cmd = new MySqlCommand("CREATE TABLE MyTable (ID Integer, Data varchar(50))", conn);

cmd.ExecuteNonQuery();


cmd = new MySqlCommand("INSERT INTO MyTable (ID, Data) VALUES (1, 'May11 2021');", conn);
cmd.ExecuteNonQuery();

Visual Studio connecting to MySQL

 Video for installing the connector:

https://youtu.be/NLv8WV43TuA


Code Project example:

https://www.codeproject.com/Articles/43438/Connect-C-to-MySQL


Code Example:

Imports System

Imports System.Data
Imports MySql.Data.MySqlClient
 
 
Module Module1
 
    Sub Main()
        Dim connstring As String = "server=sql5.freemysqlhosting.net;userid=sql5485827;password=kGXeNyGig9;database=sql5485827"
 
        Dim conn As MySqlConnection = Nothing
        Dim COMMAND As MySqlCommand
        Dim READER As MySqlDataReader
 
        Try
            conn = New MySqlConnection(connstring)
            conn.Open()
            Console.WriteLine("Connected to the Database")
            Dim Query As String
 
            Query = "insert into users (id,name) values (2,'Rhonda Rosemary')"
            COMMAND = New MySqlCommand(Query, conn)
            READER = COMMAND.ExecuteReader
            Console.WriteLine("Data Saved")
            READER.Close()
 
 
            Console.ReadLine()
            Query = "SELECT * FROM users;"
            Dim da As New MySqlDataAdapter(query, conn)
            Dim ds As New DataSet()
            da.Fill(ds, "table_usesr")
            Dim dt As DataTable = ds.Tables("table_name")
            Console.WriteLine("The data in the table is:")
            For Each row As DataRow In dt.Rows
                For Each col As DataColumn In dt.Columns
                    Console.Write(row(col).ToString() + vbTab)
                Next
 
                Console.Write(vbNewLine)
            Next
 
        Catch e As Exception
            Console.WriteLine("Error: {0}", e.ToString())
        Finally
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try
        Console.ReadLine()
    End Sub
 
End Module

JSP - Java Description

https://docs.oracle.com/javaee/5/tutorial/doc/bnair.html