Kbase P140723: How do I call a SQL-92 stored procedure from VB.NET?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/3/2009 |
|
Status: Unverified
GOAL:
How do I call a SQL-92 stored procedure from VB.NET?
FACT(s) (Environment):
Windows
OpenEdge 10.x
FIX:
The following code fragment shows how to call a simple SQL-92 stored procedure in VB.NET. The stored procedure defines a single output parameter as a string and the stored procedure just returns the value 'HelloWorld':
Dim SQLConnection As New OdbcConnection("DSN=test;UID=user;PWD=pass")
Dim SQLCommand As New OdbcCommand("{call helloWorld(?)}", SQLConnection)
Dim result As String
SQLCommand.CommandType = CommandType.StoredProcedure
SQLCommand.Parameters.Add("out_name", OdbcType.VarChar, 20)
SQLCommand.Parameters("out_name").Direction = ParameterDirection.Output
SQLConnection.Open()
SQLCommand.ExecuteNonQuery()
result = SQLCommand.Parameters("out_name").Value
SQLConnection.Close()
Console.WriteLine(result)