I am a programmer but I hate grammar. Here you will find what I did, doing , will do ... Scattered pieces of knowledge that I have deleted from my mind to the trash bin through out my boring daily coding life. I will also report some of my failures in life so dear to me not success, because I have always learnt much only when I fail.
Saturday, March 31, 2018
Tuesday, March 13, 2018
Saturday, March 3, 2018
LINQPAD - How to Insert data into MySQL using VB
This snippet connect to MySQL in LINQPAD using Visual Basic. Make sure you download the MySql.Data.DLL, unblock the zip file
then extract it and add that reference in LINQPAD by pressing F4 as shown in the video here
Main sub
Insertion sub
This is just a trick, hope it paved your way out.
Main sub
Sub Main Dim query As String Dim stid As Integer Dim name, programme As String stid = 13 name = "Nemo" programme = "Search of Nemo" query ="insert into Student(Stid,Name,Programme) values (" & stid & ",'" & name & "','" & programme & "')" insertInDB (query) End Sub
Insertion sub
Sub InsertInDB (query As String) 'Declaring variables Dim conn As New MySqlConnection() Dim sqlCmd As MySqlCommand 'Connection string to MySQL conn.ConnectionString = "Persist Security Info=False;database=springboot;server=localhost;Connect Timeout=30;user id=springboot; pwd=springboot" Try 'Connecting and executing the query conn.Open() sqlCmd = New MySqlCommand( query, conn) sqlCmd.ExecuteNonQuery() 'Closing the query conn.Close() Catch myerror As MySqlException 'Throwing exceptions Console.WriteLine("Error connecting to database!") Exit Sub End Try Console.WriteLine("connected to database!") End Sub
This is just a trick, hope it paved your way out.
Subscribe to:
Posts (Atom)