>I have a VFP stored procedure that I'm trying to use in an ASP.NET login screen. It works in VFP - if I do spLogin("mjones","pass") it will return an integer PK (or -1 if it's not valid).
>
>I'm getting an error on the ExecuteScalar command like "Variable 'Q28P2' is not found.". If I run it again it's the same message except with 'Q29P2', then 'Q30P2', etc.
>
>If I comment out the two RetVal lines I get a different error: "Function argument value, type or count is invalid."
>
>Any suggestions appreciated.
>
>=================================================
>public sub Submit(Sender as Object, e as EventArgs)
> dim intID as Integer = 0
> Dim MyConnection As New OleDbConnection("Provider=VFPOLEDB.1;" + _
> "Data Source=D:\Data\TR.dbc")
>
> dim lcLogin,lcPassword as string
> lcLogin = Login.text
> lcPassword = Pass.text
>
> dim loCommand as OleDbCommand = New OleDbCommand("spLogin",MyConnection)
> loCommand.CommandType = CommandType.StoredProcedure
>
> dim Param1 as OleDbParameter = loCommand.Parameters.Add("@Param1",OleDbType.Char)
> Param1.Direction = ParameterDirection.Input
> Param1.Value = lcLogin
>
> dim Param2 as OleDbParameter = loCommand.Parameters.Add("@Param2",OleDbType.Char)
> Param2.Direction = ParameterDirection.Input
> Param2.Value = lcPassword
>
> dim RetVal as OleDbParameter = loCommand.Parameters.Add("@RetVal",OleDbType.Integer)
> RetVal.Direction = ParameterDirection.ReturnValue
>
> MyConnection.Open()
>
> intID = loCommand.ExecuteScalar
>
> MyConnection.Close()
>
>end sub
Followup. Code snippet adding a customer via a stored proc in VFP (return value is an integer ID of added customer):
OleDbCommand loCommand = new OleDbCommand();
loCommand.Connection = loConnection;
string lcStoredProc = String.Format("CustomerAdd('{0}','{1}','{2}')",
cName,cEmail,cPassword);
loCommand.CommandText=lcStoredProc;
loCommand.CommandType=CommandType.StoredProcedure;
int liRetValue = (int)loCommand.ExecuteScalar();
loConnection.Close();
VFP stored proc looks like:
Procedure CustomerAdd(name as string,email as string,password as string) as integer
*...
return IntegerIDValue
endproc
Cetin