Namespace AutoLotConnectedLayer Public Class InventoryDAL ' This member will be used by all methods. Private sqlCn As SqlConnection = Nothing Public Sub OpenConnection(ByVal connectionString As String) sqlCn = New SqlConnection() sqlCn.ConnectionString = connectionString sqlCn.Open() End Sub Public Sub CloseConnection() sqlCn.Close() End Sub `Adding the Insertion Logic Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, ByVal make As String, ByVal petName As String) ' Format and execute SQL statement. Dim sql As String = String.Format("Insert Into Inventory " & "(CarID, Make, Color, PetName) " & "Values'{0}', '{1}', '{2}', '{3}')", id, make, color, petName) ' Execute using our connection. Using cmd As New SqlCommand(sql, Me.sqlCn) cmd.ExecuteNonQuery() End Using End Sub ... End Class End Namespace
The reason for doing the work is to create something useful that helps people. Please click the ads if my articles are useful for you. Definitely, that's not enough. My target is working at some great organizations, such that one day, all the people with internet access can benefit from the service I contributed.