Skip to content

Commit b055a4e

Browse files
committed
AddDevice logging, comments, catching
1 parent e666943 commit b055a4e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

modDatabase.vb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ Module modDatabase
133133
Return result
134134
End Function
135135

136+
''' <summary>
137+
''' Adds a device to the DEVICES table
138+
''' </summary>
139+
''' <param name="strName">Device Name</param>
140+
''' <param name="strType">Device Type</param>
141+
''' <param name="strModel">Device Model</param>
142+
''' <param name="strLocation">Device Location</param>
143+
''' <param name="strAddress">Device Address</param>
144+
''' <returns>(int) Number of rows affected</returns>
136145
Function AddDevice(ByVal strName As String, ByVal strType As String, ByVal strModel As String, ByVal strLocation As String, ByVal strAddress As String) As Integer
137146
Dim cmdAddDevice As New SQLiteCommand
138147
cmdAddDevice.CommandText = "INSERT INTO DEVICES (Name, Type, Model, Location, Address) VALUES(@name, @type, @model, @location, @address)"
@@ -142,7 +151,13 @@ Module modDatabase
142151
cmdAddDevice.Parameters.Add(New SQLiteParameter("@location", strLocation))
143152
cmdAddDevice.Parameters.Add(New SQLiteParameter("@address", strAddress))
144153
cmdAddDevice.Connection = conn
145-
Return cmdAddDevice.ExecuteNonQuery
154+
My.Application.Log.WriteEntry("SQLite: Adding " & strName & " to devices - " & cmdAddDevice.CommandText, TraceEventType.Verbose)
155+
Try
156+
Return cmdAddDevice.ExecuteNonQuery
157+
Catch SQLiteExcep As SQLiteException
158+
My.Application.Log.WriteException(SQLiteExcep)
159+
Return 0
160+
End Try
146161
End Function
147162

148163
Function Load() As String

0 commit comments

Comments
 (0)