Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored procedure for edit log
Message
From
20/11/2008 11:05:28
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01361756
Message ID:
01363204
Views:
13
>>>>Hi,
>>>>
>>>>Sorry - missed this message. Don't use Update command. Here's an example that you should be able to adapt. VFP SPs:
PROCEDURE SetUserName
>>>>LPARAMETERS cUserName
>>>>PUBLIC UserName
>>>>UserName = cUserName
>>>>ENDPROC
>>>>
>>>>FUNCTION WhoIsCurrentUser
>>>>  RETURN UserName
>>>>ENDFUNC
>>>>
>>>>.NET test code:
       static void Main(string[] args)
>>>>        {
>>>>            //Set public variable when setting up the connection
>>>>            System.Data.OleDb.OleDbConnection myConn = ConnectionProvider.CreateConnectionForUser("Jim");
>>>>
>>>>            // Now see if the public variable is accessible by SP
>>>>            System.Data.OleDb.OleDbCommand test = new System.Data.OleDb.OleDbCommand();
>>>>            test.Connection = myConn;
>>>>            test.CommandText = "WhoIsCurrentUser()";
>>>>            string s = (string) test.ExecuteScalar();
>>>>        }
>>>>    }
>>>>
>>>>
>>>>    static class ConnectionProvider
>>>>    {
>>>>        static public System.Data.OleDb.OleDbConnection CreateConnectionForUser(string sUser)
>>>>        {
>>>>            string connection = "Provider=VFPOLEDB.1;Data Source=Data1.dbc";
>>>>            System.Data.OleDb.OleDbConnection oledb = new System.Data.OleDb.OleDbConnection(connection);
>>>>            oledb.Open();
>>>>
>>>>            System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand();
>>>>            command.Connection = oledb;
>>>>            command.CommandText = "SetUserName('" + sUser + "')";
>>>>            command.ExecuteNonQuery();
>>>>             return oledb;
>>>>        }
>>>>    }
>>>>
>>>>HTH,
>>>>Viv
>>>
>>>Hi Viv,
>>>
>>>I don't think this
>>>
>>>command.CommandText = "SetUserName('" + sUser + "')";
>>>
>>>is going to work.
>>
>>Hi,
>>Why not?
>
>May be I'm wrong, but I think in CommandText you can only specify the SP name and you have to pass your parameter through Parameters collection of the Command object.

Worked for me :=}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform