Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

[RESOLVED] Problems with SQLite parameters, VB.NET

$
0
0
I'm trying to migrate my program from mdb to SQLite. In general, it is not so difficult job. I simply changed all appearances of "OleDb" to "SQLite" (search and replace option works fine).
The only errors are related with SQL parameters.

For example, If we consider thic piece of code:

vb Code:
  1. cmd.Parameters.Add(New OleDb.OleDbParameter("@ID", OleDb.OleDbType.VarChar, 20))
  2. cmd.Parameters.Add(New OleDb.OleDbParameter("@Name", OleDb.OleDbType.VarChar, 20))


and after changing of 'OleDb' to 'SQLite' we get this message:

Quote:

'System.Data.SQLite.SQLiteType' is not accessible in this context because it is 'Friend'.
it wasn't so difficult to correct this into:

Code:

cmd.Parameters.AddWithValue("@ID", 20)
cmd.Parameters.Add("@Name", 20)

well... things were much more complicated with this code:

vb Code:
  1. cmd.Parameters.AddWithValue("@fid", SQLite.SQLiteType.Char).Value = txtID.Text

it looks like that SQLite namespace doesn't contain property with name "SQLiteType" oposed to "OleDb.OleDbType". How I can correct this?

Also, there's a similar problem with this command:
vb Code:
  1. cmd.Parameters.AddWithValue("@ID", 20)
  2. cmd.Parameters.AddWithValue("@pic", SQLite.SQLiteType.Binary)

While you can change Add to AddWithWalue and remove 'OleDb.OleDbType.VarChar', how we can do the same with: 'SQLite.SQLiteType.Binary'? The 2nd parameter of 'AddWithValue' must be some numeric value but how to know which one if you're working with BLOB objects?

Viewing all articles
Browse latest Browse all 2918

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>