INSERT with transaction and parameters?

☆樱花仙子☆ 提交于 2019-12-05 16:31:50

The transaction approach should be the same (providing the SQLite API supports transactions.) As for multiple parameters, you need to declare a SqlParameter class instance for each parameter, then add each one to the query.

Dim myparam As New SQLite.SQLiteParameter()
myparam.Value = "Parameter 1's value"

Dim myparam2 As New SQLite.SQLiteParameter()
myparam2.Value = "Parameter 2's value"

SQLcommand.Parameters.Add(myparam)
SQLcommand.Parameters.Add(myparam2)

As for your question "How to tell if at least one row" the standard .NET SQLReader's have a "HasRows" property. i.e.

If SQLreader.HasRows Then
    While SQLreader.Read()
        ListBox1.Items.Add(SQLreader(1))
    End While
End If

I presume the SQLlite driver should as well.

Sorry if this code isn't clean VB, I haven't touched it in about 5 years!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!