Home All Groups Group Topic Archive Search About

vb.Net 2005 call to Teradata stored proc

Author
10 Jan 2007 5:21 PM
marcmc
Hey,

The below function won't build for me at the two Statements below attempting
to add
parameters to a dynamic stored procedure call. I just cannot find the
correct syntax using Teradata.
My procedure takes 3 parameters: (IN v_pWho VARCHAR(20), IN v_i_run_job_id
INT, OUT v_return_code INT))

Error: "Too many arguments to 'Public MustOverride Function Add(value As
Object) As Integer'."

looks like dbCommand (from .NET Data Provider for Teradata -
Teradata.Client.Provider) can only support 1 parameter. Any ideas how to fix.
This worked fine in SQLServer using VS 2003 and SqlClient.SqlCommand.


cmd.Parameters.Add("@pWho", UNameRoutine)
cmd.Parameters(0).Direction = ParameterDirection.Input

cmd.Parameters.Add("@pRESULT", SqlDbType.Int)
cmd.Parameters(1).Direction = ParameterDirection.Output


-- EXAMPLE CODE
'Vars declarations
'.NET Data Provider for Teradata - Teradata.Client.Provider
Dim cn As DbConnection
Dim cmd As DbCommand
Dim dtr, dtr1 As DbDataReader
Dim strSQL As String
Dim cmdSelect As DbCommand
Dim cnString As String
Dim pf As DbProviderFactory =
DbProviderFactories.GetFactory("Teradata.Client.Provider")

' Function Code
Private Function RunExecRoutines() As Boolean
Try
cnString = "Data Source=" & Server.Text & ";User ID=" &
UserName.Text & ";Password=" + Password.Text
cn = pf.CreateConnection
cn.ConnectionString = cnString
cn.Open()
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try

cmd = pf.CreateCommand
cmd.Connection = cn

cmd.CommandText = ProcToExec
cmd.CommandTimeout = 9000
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@pWho", UNameRoutine)
cmd.Parameters(0).Direction = ParameterDirection.Input

cmd.Parameters.Add("@pRESULT", SqlDbType.Int)
cmd.Parameters(1).Direction = ParameterDirection.Output

Try
cmd.ExecuteNonQuery()
Catch ex As Exception
sqlCnError = ("Error: Could not execute " + ProcToExec + "
stored procedure")
MessageBox.Show(sqlCnError, "MIS RECON Engine",
MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
End Try

cmd.Dispose()
cn.Close()
cn.Dispose()
End Function

Author
20 Mar 2007 11:47 AM
Fawad Asrar Qureshi
I have a similar problem. Did you find any solution to this?

Regards

FAQ

Show quote
"marcmc" wrote:

> Hey,
>
> The below function won't build for me at the two Statements below attempting
> to add
> parameters to a dynamic stored procedure call. I just cannot find the
> correct syntax using Teradata.
> My procedure takes 3 parameters: (IN v_pWho VARCHAR(20), IN v_i_run_job_id
> INT, OUT v_return_code INT))
>
> Error: "Too many arguments to 'Public MustOverride Function Add(value As
> Object) As Integer'."
>
> looks like dbCommand (from .NET Data Provider for Teradata -
> Teradata.Client.Provider) can only support 1 parameter. Any ideas how to fix.
> This worked fine in SQLServer using VS 2003 and SqlClient.SqlCommand.
>
>
> cmd.Parameters.Add("@pWho", UNameRoutine)
> cmd.Parameters(0).Direction = ParameterDirection.Input
>
> cmd.Parameters.Add("@pRESULT", SqlDbType.Int)
> cmd.Parameters(1).Direction = ParameterDirection.Output
>
>
> -- EXAMPLE CODE
> 'Vars declarations
> '.NET Data Provider for Teradata - Teradata.Client.Provider
> Dim cn As DbConnection
> Dim cmd As DbCommand
> Dim dtr, dtr1 As DbDataReader
> Dim strSQL As String
> Dim cmdSelect As DbCommand
> Dim cnString As String
> Dim pf As DbProviderFactory =
> DbProviderFactories.GetFactory("Teradata.Client.Provider")
>
> ' Function Code
> Private Function RunExecRoutines() As Boolean
> Try
> cnString = "Data Source=" & Server.Text & ";User ID=" &
> UserName.Text & ";Password=" + Password.Text
> cn = pf.CreateConnection
> cn.ConnectionString = cnString
> cn.Open()
> Catch ex As Exception
> sqlCnError = ("Error: Could not establish database connection")
> End Try
>
> cmd = pf.CreateCommand
> cmd.Connection = cn
>
> cmd.CommandText = ProcToExec
> cmd.CommandTimeout = 9000
> cmd.CommandType = CommandType.StoredProcedure
>
> cmd.Parameters.Add("@pWho", UNameRoutine)
> cmd.Parameters(0).Direction = ParameterDirection.Input
>
> cmd.Parameters.Add("@pRESULT", SqlDbType.Int)
> cmd.Parameters(1).Direction = ParameterDirection.Output
>
> Try
> cmd.ExecuteNonQuery()
> Catch ex As Exception
> sqlCnError = ("Error: Could not execute " + ProcToExec + "
> stored procedure")
> MessageBox.Show(sqlCnError, "MIS RECON Engine",
> MessageBoxButtons.OK, _
> MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
> End Try
>
> cmd.Dispose()
> cn.Close()
> cn.Dispose()
> End Function
>

AddThis Social Bookmark Button