PROCEDURE SetUserName >LPARAMETERS cUserName >PUBLIC UserName >UserName = cUserName >ENDPROC > >FUNCTION WhoIsCurrentUser > RETURN UserName >ENDFUNC>
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; > } > }>