我有以下代码:
Shared Sub ExecSQL(ByVal connection As SQLiteConnection, ByVal commandText As String, Optional ByVal param As Object = Nothing)
If connection Is Nothing Then
Throw New NullReferenceException("Connection required!")
End If
If connection.State <> ConnectionState.Open Then
connection.Open()
End If
connection.Execute(commandText, param)
End Sub
Shared Sub SaveFingerPrints(p As Person)
For Each f In p.Fingerprints
ExecSQL($"insert into Prints(id,finger,image,template) values({p.Id},{f.Finger},{f.AsImageData},{f.Template});")
Next
End Sub
我最终得到以下插入语句:
insert into Prints(id,finger,image,template) values(1,RightThumb,System.Byte[],System.Byte[]);
请问我该如何解决
最佳答案
得到它了!
Shared Sub SavePrints(p As Person)
For Each f In p.Fingerprints
cn.Execute("insert into Prints(id,finger,image,template) values(@id,@Finger,@image,@template)",
New With {
.id = p.Id,
.finger = CInt(f.Finger),
.image = f.AsImageData,
.template = f.Template})
Next
End Sub