I'm trying to run this program but it gave me an error, I have checked everything like server name, database name, but I don't know where I made a mistake.
Please help out to solve this problem
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection("Server=PAULIN\LARIE4; database=TermPaper;")
Dim da As New SqlDataAdapter()
Dim dt As New DataTable
Dim ds As New DataSet
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ld()
End Sub
Private Sub clearControls()
txtN.Text = ""
txtP.Text = ""
End Sub
Private Sub clrbinding()
ds.Tables(0).Rows.Clear()
dt.Rows.Clear()
DataGridView1.DataSource = Nothing
End Sub
Private Sub ld()
da.SelectCommand = New SqlCommand
da.SelectCommand.Connection = New SqlConnection
da.SelectCommand.CommandText = "select *from termpaper1"
da.SelectCommand.CommandType = CommandType.Text
con.Open()
da.Fill(ds, "termpaper1")
con.Close()
dt = ds.Tables("termpaper1")
DataGridView1.DataSource = dt
End Sub
Private Sub btnInser_Click(sender As Object, e As EventArgs) Handles btnInser.Click
clearControls()
clrbinding()
End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
da.InsertCommand = New SqlCommand
da.InsertCommand.Connection = New SqlConnection
da.InsertCommand.CommandText = "insert into termpaper1(user_name,password)values('" & txtN.Text & "','" & txtP.Text & "')"
da.InsertCommand.CommandType = CommandType.Text
con.Open()
da.InsertCommand.ExecuteNonQuery()
MsgBox("one record added")
clrbinding()
ld()
End Sub
End Class