Hi all. Could someone pls tel me whats wrong with my code for adding new records to the db. Nothing is being added to the db and before the form opens up when running it, it brings an error that the file name of my form is invalid. Could someone pls help in this problem. Its weighing me down!
Code in the form load
strsql = "SELECT * FROM Landlord ORDER BY Landlord ASC"
Dim cmd As New OleDbCommand(strsql, oledbcon)
da = New OleDbDataAdapter(cmd)
ds = New DataSet
da.Fill(ds, "Landlord")
dt = ds.Tables(0)
txtid.DataBindings.Add("Text", dt, "LandlordID")
txtplot.DataBindings.Add("Text", dt, "Plot No")
txtname.DataBindings.Add("Text", dt, "Name")
txtaddress.DataBindings.Add("Text", dt, "Address")
txttel.DataBindings.Add("Text", dt, "Tel No")
txtbank.DataBindings.Add("Text", dt, "Bank")
txtac.DataBindings.Add("Text", dt, "A/C No")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Me.Text)
End Try
Code in the button Add
Try
If flag Then
strsql = "INSERT INTO Landlord(LandlordID,Plot No,Name,Address,Tel No,Bank,A/C No)" & _
"VALUES ('" & txtid.Text & "','" & txtplot.Text & "','" & txtname.Text & "','" & txtaddress.Text & "','" & txttel.Text & "','" & txtbank.Text & "','" & txtac.Text & "')"
oledbcon.Open()
Dim cmd As New OleDbCommand(strsql, oledbcon)
cmd.ExecuteNonQuery()
oledbcon.Close()
End If
cur = New Landlord
cur.Show()
Me.Hide()
MsgBox("Data Added Successfully !", MsgBoxStyle.Information, Me.Text)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Me.Text)
End Try