Code:
Private Sub SaveButton_Click(sender As System.Object, e As System.EventArgs) Handles SaveButton.Click
Dim con As New SqlConnection
Dim AID As String = AgentIDNum.AgentIDNumber
Dim GDate As String = GetDateModule.GetDate
Try
con.ConnectionString = ("Data Source=ANDY-PC\LETTINGS;Initial Catalog=easylet_database;User Id=sa;Password=g3m1n1;")
con.Open()
Dim cmd As New SqlCommand("INSERT INTO Landlord(Title,FirstName,LastName,Email,Telephone,Telephone2,Fax,Source,Address1,Address2,Address3,Address4,PostCode,Occupation,Bank_Number,Bank_Sortcode,Bank_AccountName,Bank_Company,Notes,Inactive,Date) VALUES (@Title,@FirstName,@LastName,@Email,@Telephone,@Telephone2,@Fax,@Source,@Address1,@Address2,@Address3,@Address4,@PostCode,@Occupation,@Bank_Number,@Bank_Sortcode,@Bank_AccountName,@Bank_Company,@Notes,@Inactive,@Date)",con)
cmd.Parameters.AddWithValue("@Title", Title.Text)
cmd.Parameters.AddWithValue("@FirstName", FirstName.Text)
cmd.Parameters.AddWithValue("@LastName", LastName.Text)
cmd.Parameters.AddWithValue("@Email", Email.Text)
cmd.Parameters.AddWithValue("@Telephone", Telephone.Text)
cmd.Parameters.AddWithValue("@Telephone2", Telephone2.Text)
cmd.Parameters.AddWithValue("@Fax", Fax.Text)
cmd.Parameters.AddWithValue("@Source", Source.Text)
cmd.Parameters.AddWithValue("@Address1", Address1.Text)
cmd.Parameters.AddWithValue("@Address2", Address2.Text)
cmd.Parameters.AddWithValue("@Address3", Address3.Text)
cmd.Parameters.AddWithValue("@Address4", Address4.Text)
cmd.Parameters.AddWithValue("@Postcode", Postcode.Text)
cmd.Parameters.AddWithValue("@Occupation", Occupation.Text)
cmd.Parameters.AddWithValue("@Bank_Number", Bank_Number.Text)
cmd.Parameters.AddWithValue("@Bank_Sortcode", Bank_Sortcode.Text)
cmd.Parameters.AddWithValue("@Bank_Accountname", Bank_Accountname.Text)
cmd.Parameters.AddWithValue("@Bank_Company", Bank_Company.Text)
cmd.Parameters.AddWithValue("@Notes", Notes.Text)
cmd.Parameters.AddWithValue("@Inactive", 0)
cmd.Parameters.AddWithValue("@AgentID", AID)
cmd.Parameters.AddWithValue("@Date", GDate)
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error creating Landlord - Please contact Support")
Finally
con.Close()
Me.Close()
End Try
End Sub