there is a login in the app which does something as it
this is in production and could not be modified
xconec = Sqlstringconnect("Driver={SQL Server};Server=laptop001;Database=Master;Uid=sa;Pwd=sa;")
&& syslanguages es una tabla que se encuentra contenida en la BD Master de SQL Server
xselect = "SELECT * from syslanguages"
xenvio = SQLExec(xconec,xselect,"Micursor")
then always in all form or prg in fox i am using a code similar to
xenvio = SQLExec(xconec,xselect,"Micursor")
then if i do it in all modules, how can i get my connection? well i need
user,db,password,server
this is because i want to call a c# app (an exe) which is going to connect to the same server/database for do inserts. but i have only xconect variable
Use SQLGETPROP().
xpassword = SQLGETPROP(xconect, "Password")
Or:
xstring = SQLGETPROP(xconect, "ConnectString")
and then parse xstring for the pieces that you're looking for.
This works in VFP 9, not sure about VFP 6.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last month.
Improve this question
I started studying Ruby recently and I was looking for a challenge so I decided to create this program.
I created a program using hash, to create a list of products, where it stores the name and value.
However, I would like the products registered within the hash to remain there even after finishing the program.
Can anyone tell me if this is possible and how I could do it?
code
The hash and every other variable will always be cleared from memory when your program ends. While your program is running, it stores everything in the RAM, and then clear all the memory it's using after finishing.
In order to recover the value from your Hash after exiting your program, you need to persist this information somehow. Using a database or storing it in a file. As someone suggested, you could store it in a JSON file, for example. You could do it like this:
Create an empty file in the same directory of your Ruby script named products.json
Use the Ruby json library to load the file content as a hash at the start of your program
Update the file before exiting the program
A working example:
require 'json'
begin
products = JSON.parse(File.read('products.json'))
rescue StandardError
puts 'Ainda não existem produtos cadastrados. Criando nova lista'
products = {}
end
loop do
puts 'Escolha uma opção'
puts '1 - Adicionar o item e o valor'
puts '2 - Sair'
print 'Opção: '
option = gets.chomp.to_i
if option == 1
print 'Digite o nome do item: '
key = gets.chomp
print 'Digite o valor do item: '
value = gets.chomp
puts "O produto #{key} com o valor de R$#{value} foi cadastrado com sucesso!"
products[key] = value
elsif option == 2
File.open('products.json', 'w').write(JSON.pretty_generate(products))
puts 'Fim'
break
else
puts 'Opção inválida'
end
end
I'm runing a sql request in a model to get some data in relation.
I got a array called newScoring with ["_646_maturity", "_660_maturity", "_651_maturity", "_652_maturity", "_641_maturity"]
newScoring.each do |e|
numero = e.from(1).to(-10) // remove text to get only number : 646
sql = "SELECT * FROM pratiques WHERE numero LIKE '%"+numero+"%'" // sql request to get a pratique with numero equal to my previous number
records_array = ActiveRecord::Base.connection.execute(sql)
Rails.logger.debug "SQL : "+records_array
end
When I log records_array.inspect, I got
[{"id"=>1, "numero"=>646, "titre"=>"Acquérir en priorité des équipements reconditionnés", "ponderation"=>3, "texte_kpi"=>"% du parc reconditionné", "section"=>"achats-responsables", "created_at"=>"2019-06-03 14:10:14.228234", "updated_at"=>"2019-06-03 14:10:14.228234"}]
I want to access to ponderation value but I didn't find any docs related. I tried differents things but got errors messages with string conversion.
Thanks for the help!
Since records_array is an Array of Hashes you need to first select the row (Hash) you want and then access the desired column:
records_array.first['ponderation'] # or records_array[0]['ponderation']
=> 3
Btw, if you are on Rails, why don't you generate a model for practiques and use ActiveRecord?
I have the following script that maps printers based on AD grouping:
'---------------------------------------------------------------------------------------------
'-------------------------------MAPEAMENTO DE IMPRESSORAS-------------------------------------
on error resume next
'determines the user who just logged on
Set objSysInfo = CreateObject("ADSystemInfo")
Set WSHNetwork = CreateObject("WScript.Network")
'As soon as we tack on LDAP:// and construct an ADsPath we then bind to the user account in
'Active Directory and report back the groups the user belongs to; this can be done simply
'by enumerating the values in the MemberOf attribute.
strUserPath = "LDAP://" & Replace(objSysInfo.UserName, "/", "\/")
Set objUser = GetObject(strUserPath)
For Each objGroup in objUser.Groups
strGroupName = objGroup.CN
'---------------------------------------------------------------------------------------------
'--------------MAPEAMENTO DE IMPRESSORA DO GRUPO UM-------------------------------------------
'Mapeamento de impressoras por grupo definindo a impressora comom padrão para aquele grupo.
Select Case strGroupName
Case "GrupodoAD1"
WshNetwork.AddWindowsPrinterConnection "\\servidor\impressora1"
WshNetwork.SetDefaultPrinter "\\servidor\impressora1"
End Select
'---------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------
'--------------MAPEAMENTO DE IMPRESSORA DO GRUPO DOIS-----------------------------------------
'Mapeamento de impressoras por grupo definindo a impressora comom padrão para aquele grupo.
Select Case strGroupName
Case "GrupodoAD2"
WshNetwork.AddWindowsPrinterConnection "\\servidor\impressora2"
WshNetwork.SetDefaultPrinter "\\servidor\impressora2"
End Select
'---------------------------------------------------------------------------------------------
'==========Adicione seções adicionais de case para cada grupo do AD que tiver.+===============
next
Now I was asked to delete some local printers on user's computers. The above script runs on logon. The condition although states that only certain printers must be deleted (some users take computers home and we do not want to delete their home printers).
Is there a way I can accomplish this using the above existing script? How can I do that and where do I insert the information? Can I delete more than 1 printer using a single script?
For example I know I must delete:
Samsung SCX-6545X Series PCL 6
Samsung SCX-6545X Series PCL 5
Samsung SCX-6545X Series PS
If I have similar names like above, can I use that to delete any printer that matches parts of the name?
Best regards and thanks in advance for your help!
This is a script I found from somewhere once and adapted slightly to delete printers by device name. Please approach with caution, understand it, and adapt it to your needs carefully:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet P1505'")
For Each objPrinter In colInstalledPrinters
objPrinter.Delete_
Next
I think you could replace the equals clause in the "SELECT" statement to use a "IN" so you could check all the printers and delete them in one hit. Example:
("Select * from Win32_Printer where DeviceID In ('HP LaserJet P1505', 'Printer_2', 'Printer_3')")
I'm building a WebWorks version of an Android app that's localised into 39 languages.
At the moment all the localisations are in xml files of key-value pairs, one file per language .
Each language file has about 400 lines (roughly 40k per file).
Users can change the language used in app.
What options are there in WebWorks to solve this kind of situation?
I'd be more than happy to convert the resource files into any other kind of format to make working with it a better experience on the platform.
You could store each language set in a JavaScript file that you include/load as needed. (I've converted the XML data to a "Map" since it is just key/value pairs)
e.g. (just ignore my translations... I just Googled this, I'm by no means fluent in Spanish)
//Spanish File "lang_spanish.js"
var translations = {
"lose_a_turn": "pierde un turno",
"do_not_pass_go": "huele como un camello",
"take_a_card": "tener una tarjeta de",
"you_win_the_game":"sin motocicletas en la biblioteca",
"you_can_not_move":"desbordamiento de la pila puede ser un lugar divertido"
};
In your <head> you can then have a generic script tag, that you just change the source of as needed.
e.g.
<script id="langFile" src="js/lang_english.js"></script>
When you want a different language, just remove this script from the DOM and add your new one. e.g.
function switchLang(langName){
var headTag = document.getElementsByTagName('head')[0];
var scriptFile = document.getElementById('langFile');
headTag.removeChild(scriptFile);
var newScript = document.createElement('script');
newScript.id = 'langFile';
newScript.src = 'js/lang_' + langName + '.js';
headTag.appendChild(newScript);
}
//call with:
switchLang('spanish');
The alternative would be to load all 39 languages by default... but that seems like overkill considering most will only ever want 1 or 2.
I'm trying to use EWS to search a Task folder on Exchange 2010. I'm trying to limit the due dates of the Tasks returned, but unfortunately there's no equivalent to the CalendarView for the Task folder, so I have to use a FindItem search.
I'm using Java, Axis2 and I prepare the query like this:
// fiType is, obviously, a FindItemType
RestrictionType rType = fiType.addNewRestriction();
IsGreaterThanOrEqualToType igtoretType = IsGreaterThanOrEqualToType.Factory.newInstance();
igtoretType.addNewFieldURI().setFieldURI(UnindexedFieldURIType.TASK_DUE_DATE);
igtoretType.addNewFieldURIOrConstant().addNewConstant().setValue(dateFormat.format(begCal.getTime()));
IsLessThanOrEqualToType iltoretType = IsLessThanOrEqualToType.Factory.newInstance();
iltoretType.addNewFieldURI().setFieldURI(UnindexedFieldURIType.TASK_DUE_DATE);
iltoretType.addNewFieldURIOrConstant().addNewConstant().setValue(dateFormat.format(endCal.getTime()));
SearchExpressionType[] seArr = new SearchExpressionType[2];
seArr[0] = igtoretType;
seArr[1] = iltoretType;
AndType aType = rType.addNewAnd();
aType.setSearchExpressionArray(seArr);
Unfortunately, I get this error:
org.apache.axis2.AxisFault: La demande a échoué lors de la validation du schéma : L'élément 'http://schemas.microsoft.com/exchange/services/2006/types:SearchExpression' est abstrait ou son type l'est.
Roughly translated from French, it means that the query failed because the type SearchExpression is abstract, or it's type is.
After searching, I found this article explaining how to modify the types.xsd file to take care of this. However, even after applying the modifications, I still get the same error.
I'm at a loss as to how to go about solving this. Any help would be appreciated.
Another option is EWS Java API by Microsoft...