vb.net 调用oracle中存储过程

前端之家收集整理的这篇文章主要介绍了vb.net 调用oracle中存储过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

存储过程的实例:
PROCEDURE TEST_C(temp out varchar2,a INvarchar2,b in varchar2)
IS
BEGIN
temp:=a || b;
END;

调用方法:
说明:要在程序开头加入Imports System.Data.OleDb

Dim dbConn As New OleDbConnection
Dim dbComm As OleDbCommand

dbConn.ConnectionString = "Provider=MSDAORA.1;User ID=xxx;Password=xxx;Data Source=xxx;"
dbConn.Open()
dbComm = dbConn.CreateCommand

dbComm.Parameters.Add("temp",OleDbType.VarChar,30).Direction = ParameterDirection.Output
dbComm.Parameters.Add("a",30).Direction = ParameterDirection.Input
dbComm.Parameters("a").Value = "test "
dbComm.Parameters.Add("b",30).Direction = ParameterDirection.Input
dbComm.Parameters("b").Value = "OK"

dbComm.CommandText = "{CALL TEST_C(?,?,?)}" '这里就是使用"?"来代替参数
dbComm.CommandType = CommandType.Text
dbComm.ExecuteNonQuery()
dbConn.Close()

MessageBox.Show(dbComm.Parameters("temp").Value)

猜你在找的VB相关文章