Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need to return a value from VFP stored procedure
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00772287
Message ID:
00772297
Vues:
8
Hi Jeff,

The VFP OLEDB provider does not support ParameterDirection.ReturnValue. You will need to use ExecuteScalar and remove the CustID parameter.
liCustomerID = CType(loCommand.ExecuteScalar(),Integer)
>Has anyone had success at retrieving a value returned from a VFP8 stored procedure? Here's my SP code:
>
>
>FUNCTION CustomerAdd(tcName, tcEmail, tcPassword)
>  INSERT INTO Customers ;
>     (cName,            ;
>      cEmail,           ;
>      cPassword)        ;
>    VALUES              ;
>     (tcName,           ;
>      tcEmail,          ;
>      tcPassword)
>
>  RETURN CustomerID
>ENDFUNC
>
>and here's my VB.Net code:
>
>Public Function AddCustomer(ByVal tcName As String, ByVal tcEmail As String, ByVal tcPassword As String) As Integer
>  Dim loConnection As OleDbConnection
>  Dim loCommand As OleDbCommand
>  Dim loCustID As OleDbParameter
>
>  Dim lcConnectString As String
>  Dim liCustomerID As Integer
>
>  lcConnectString = "Provider=vfpoledb;Data Source=" & Server.MapPath(".") & "\Data\ss.dbc;Nulls=1"
>  loConnection = New OleDbConnection(lcConnectString)
>  loConnection.Open()
>
>  loCommand = New OleDbCommand()
>  loCommand.Connection = loConnection
>  loCommand.CommandText = "SET NULL OFF\r\nSET DELETED ON"
>  loCommand.ExecuteNonQuery()
>
>  loCommand = New OleDbCommand()
>  loCommand.Connection = loConnection
>  loCommand.CommandText = "CustomerAdd"
>  loCommand.CommandType = CommandType.StoredProcedure
>
>  loCustID = New OleDbParameter()
>  loCustID = loCommand.Parameters.Add("CustomerID", OleDbType.Integer)
>  loCustID.Direction = ParameterDirection.ReturnValue
>
>  loCommand.Parameters.Add("Name", OleDbType.Char)
>  loCommand.Parameters.Add("Email", OleDbType.Char)
>  loCommand.Parameters.Add("Password", OleDbType.Char)
>
>  loCommand.Parameters("Name").Value = tcName
>  loCommand.Parameters("Email").Value = tcEmail
>  loCommand.Parameters("Password").Value = tcPassword
>
>
>  loCommand.ExecuteNonQuery()
>  loConnection.Close()
>
>  liCustomerID = CInt(loCustID.Value)
>
>  Return liCustomerID
>End Function
>
>
>I'm getting an error on the ExecuteNonQuery() line:
>
>
>System.Data.OleDb.OleDbException: Variable 'Q5P0' is not found.
>
>
>Oddly, the integer after the 'Q' increments every time I run the code.
>
>Strange stuff, don't you think?
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform