Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling VFP Stored Proc
Message
De
01/07/2005 05:26:15
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
Visual FoxPro
Divers
Thread ID:
01027785
Message ID:
01028051
Vues:
11
>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):
// Prepare and open loConnection
// cName, cEmail ... are filled from form elements

	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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform