请教PostgreSQL参数化查询的参数问题
示例代码:
'......
Dim Sql As String = "select pno from tb where code=$1 "
Dim cn As NpgsqlConnection = New NpgsqlConnection(cnString)
cn.Open()
Dim cmd As NpgsqlCommand = New NpgsqlCommand(sql, cn)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add(New NpgsqlParameter( _
"$1", NpgsqlTypes.NpgsqlDbType.Varchar, 6)).Value = "001"
Dim rd As NpgsqlDataReader
rd = cmd.ExecuteReader
'.......
返回错误:
ERROR: 42P02: there is no parameter $1
同样的代码,如果用CommandType.StoredProcedure调用PostgreSQL函数没有问题
请教CommandType.Text下,SQL语句的参数怎么写?谢谢先!
(网上没有到相关资料,郁闷......)