User Interface:
Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sqlconn As New OleDb.OleDbConnection
Dim sqlquery As New OleDb.OleDbCommand
Dim con As String
con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\admin\Documents\Database1.accdb"
sqlconn.ConnectionString = con
sqlquery.Connection = sqlconn
sqlconn.Open()
sqlquery.CommandText = "INSERT INTO student([username],[password])VALUES(@username,@password)"
sqlquery.Parameters.AddwithValue("@username", TextBox1.Text)
sqlquery.Parameters.AddwithValue("@password", TextBox2.Text)
sqlquery.ExecuteNonQuery()
sqlconn.Close()
MessageBox.Show("Registration Successful")
End Sub
End Class
Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sqlconn As New OleDb.OleDbConnection
Dim sqlquery As New OleDb.OleDbCommand
Dim con As String
con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\admin\Documents\Database1.accdb"
sqlconn.ConnectionString = con
sqlquery.Connection = sqlconn
sqlconn.Open()
sqlquery.CommandText = "INSERT INTO student([username],[password])VALUES(@username,@password)"
sqlquery.Parameters.AddwithValue("@username", TextBox1.Text)
sqlquery.Parameters.AddwithValue("@password", TextBox2.Text)
sqlquery.ExecuteNonQuery()
sqlconn.Close()
MessageBox.Show("Registration Successful")
End Sub
End Class
Output:
Comments
Post a Comment
If you have any query, please let us know