System.Data.SQLite parameters are not replaced

            conn = new SQLiteConnection("Data Source=nk.db");
            var items = from n in internalMap.storage select n.paramName;
            conn.Open();

            cmd = new SQLiteCommand("CREATE TABLE @table_name (name TEXT)",conn);

            //create table for the index

            cmd.Parameters.AddWithValue("@table_name", j);



            cmd.ExecuteNonQuery();

When this line is executed "cmd.ExecuteNonQuery ();" I get the following exception

"SQLite error near \" @table_name \ ": syntax error"

All the search queries I have done show that you are doing this.

I do not know what is wrong.

+3
source share
1 answer

In most of the databases I worked with, DDL commands cannot be parameterized in this way, and even DML instructions cannot be parameterized by the table name (or the name of the field, etc.). Normally, you can parameterize only the values โ€‹โ€‹of an expression.

, , , , , , /... SQL, , , , .

+5

All Articles