示例代码:'......
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语句的参数怎么写?谢谢先!
(网上没有到相关资料,郁闷......)
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语句的参数怎么写?谢谢先!
(网上没有到相关资料,郁闷......)
解决方案 »
- 关于如何debug伪静态网站问题
- 如何用div+css实现弹出一个登录页面并使当前页不可用
- 求帮助。大侠帮忙解决下。
- 怎样读取log文本文件并按照列显示在页面(gridview ?)中
- asp.net 调用dll 时遇到的问题
- 高分求刚刚作的一个功能的评估
- IIS6建立.*通配符应用程序映射的问题
- 多个dropdownlist的selectedvalue值为一体
- dataset转excel出现无法注册Microsoft Office 11.0 Object Library?
- CNZZ数据银行API有C#-SDK吗?
- ListItem的对象现实未定的值
- [50分两问]关于.net中的存储过程问题
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( _
":Param1", NpgsqlTypes.NpgsqlDbType.Varchar, 6)).Value = "001"
这事我弄了一上午......不能急了