执行Postgresql存储过程时发生VB.NET错误
从VB.Net(2019)执行Postgresql(版本11)时出错 我正在Postgresql 11上执行VB.NET 2019中的存储过程。错误详细信息如下所示 Npgsql.postgresception:'42809:spx_temp_to_ext()是一个过程' 存储过程在Postgresql server上正常工作,没有任何输入参数执行Postgresql存储过程时发生VB.NET错误,vb.net,postgresql,stored-procedures,Vb.net,Postgresql,Stored Procedures,从VB.Net(2019)执行Postgresql(版本11)时出错 我正在Postgresql 11上执行VB.NET 2019中的存储过程。错误详细信息如下所示 Npgsql.postgresception:'42809:spx_temp_to_ext()是一个过程' 存储过程在Postgresql server上正常工作,没有任何输入参数 Dim SQLCONN As New Npgsql.NpgsqlConnection Dim SQLCMD As New Npgsql.NpgsqlCo
Dim SQLCONN As New Npgsql.NpgsqlConnection
Dim SQLCMD As New Npgsql.NpgsqlCommand
SQLCONN.ConnectionString =
"SERVER=localhost;PORT=5432;DATABASE=xxxx;Uid=postgres;Password=xxxx"
SQLCMD.Connection = SQLCONN
SQLCMD.CommandType = CommandType.StoredProcedure
SQLCMD.CommandText = "spx_temp_to_ext"
SQLCONN.Open()
SQLCMD.ExecuteNonQuery()
SQLCONN.Close()
获取错误“42809:spx_temp_to_ext()是一个过程”,尽管命令类型定义为存储过程,但发现了该问题。通过使用commandtype作为存储过程,在VB.Net中自动生成select语句。为了保持向后兼容性,不能使用select语句调用Postgresql存储过程,我们需要为此使用Call方法 就这样吧
command.text = "Call Stored_Procedure_Name()"
发现了问题。通过使用commandtype作为存储过程,在VB.Net中自动生成select语句。为了保持向后兼容性,不能使用select语句调用Postgresql存储过程,我们需要为此使用Call方法 就这样吧
command.text = "Call Stored_Procedure_Name()"