Reputation: 41
my table
CREATE TABLE tbl_region
(
id integer,
"desc" character varying(100)
)
and the following is the code that i wrote in VB.NET
to INSERT
into the above mentioned table
Using conn As New NpgsqlConnection("Server=" & gstrServerName & ";Port=" & gstrPort & ";Database=" & gStrDBName & ";Username=" & gstrUserName & ";Password=" & gPassword)
conn.Open()
Dim cmd As New NpgsqlCommand
cmd.Connection = conn
cmd.CommandText = _
"INSERT INTO TBL_REGION(ID,DESC)" & _
"VALUES(@ID,@DESC)"
Dim paramID As NpgsqlParameter = New NpgsqlParameter("@ID", NpgsqlTypes.NpgsqlDbType.Integer)
Dim paramDESC As NpgsqlParameter = New NpgsqlParameter("@DESC", NpgsqlTypes.NpgsqlDbType.Char, 100)
paramID.Value = 1
paramDESC.Value = "worlds region"
cmd.Parameters.Add(paramID)
cmd.Parameters.Add(paramDESC)
cmd.Prepare()
cmd.ExecuteNonQuery()
End Using
and am getting ERROR: 42601: syntax error at or near "DESC"
on
cmd.Prepare()
Database : Postgresql
Upvotes: 0
Views: 249
Reputation: 2715
DESC
is a reserved keyword in SQL. Use some other name like "DESCRIPT
" and you should be fine
Upvotes: 1