Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to return a value from VFP stored procedure
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Need to return a value from VFP stored procedure
Miscellaneous
Thread ID:
00772287
Message ID:
00772287
Views:
130
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?

Read about the greatest fraud in the history of mankind.
See TaxableIncome.net.
Next
Reply
Map
View

Click here to load this message in the networking platform