Tuesday, May 11, 2021
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:
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
Subscribe to:
Posts (Atom)
JSP - Java Description
https://docs.oracle.com/javaee/5/tutorial/doc/bnair.html
-
In a regular annotation note, create a stack that looks the way you like. It will take a couple of trial and error attempts since there'...
-
I just finished a 1 hour marketing meeting with an organization that I volunteer with. They are trying to create an new website and the look...