Q:

vb.net escape reserved keywords in sql statement

I'm trying to execute an sql statement in vb.net to an Access database, I am escaping the reserverd word using square brackets [].  This has worked in all my SELECT statements within the program. 
The reserved word is level
But the SQL statement below fails saying 

Syntax error in INSERT INTO statement. 

If I directly copy the statement and execute this in Access it works fine
datalayer.getDataTable(String. Format("INSERT INTO users (username, password, [level]) VALUES ({0}, {1}, {2})", username, password, level))

The above statement works if I remove [level] and replace this with another column name. 
Thanks. 

A:

You're not enclosing your values in quotation marks.   Try this:
datalayer.getDataTable(String. Format(
 "INSERT INTO users (username, password, [level]) VALUES ('{0}', '{1}', '{2}')", 
 username, password, level))

However, as Andrew says, you should really use parameters.   In Access SQL (David W Fenton will come along shortly and say it's "Jet" SQL) you have to use positional parameters.   Your statement would then look like this:
INSERT INTO users (username, password, [level]) VALUES (?, ?, ?) 

You'd need to create OleDbParameter objects with the correct values, and an OleDbCommand with the text above to execute in order to do your insert.