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
Comments
Post a Comment