Please i would ask you to post in your efforts first and then ask for assistance as connectivity is the basic along with DML which is thought in colleges or class as part of .NET....
Now coming to your query
use a primary key constraint with your table for the value which you want to keep unique
now coming to the connectivity part hers the code
Imports System.Data.SqlClient 'use this namespace
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' it will first check whether the textbox contains data or not
If TextBox1.TextLength = 0 Then
'if textbox does not contain data then prompt the user to enter data
'with the help of messagebox
MessageBox.Show("value missing")
Else
'creating the object of sqlconnection class and setting its
'connectionstring property
Dim con As SqlConnection = New SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True")
'open the connection
con.Open()
'set the command by creating the object of sqlcommand class
Dim cmd As SqlCommand = New SqlCommand("insert into mytable values('" + TextBox1.Text + "')", con)
'execute the query
Dim x As Integer = cmd.ExecuteNonQuery()
If (x <> 0) Then
'once the data is added display this messagebox to user
MessageBox.Show("data added")
End If
'close the connection in the end
con.Close()
End If
End Sub
End Class
Do rate my answer once you find it useful
Thanks & Regards
Radix :rose: