Hello,
I know this subject has been already treated but I still have issue with.
So, I tried the code I've saw on the forum :
[language=]
using Ranorex.Core.Data;
...
string dataCacheName = "<Put the name of your data connector here>";
string newQueryString = string.Format("EXEC usp_TimeCodesPerDU {0}", DU_ID); //assuming your unique ID is an int value, otherwise you need to wrap the {0} with single quotes like: '{0}'
DataCache dc = DataSources.Get(dataCacheName);
((SqlDataConnector)dc.Connector).Query = newQueryString;
dc.Load();
[/language]
Here my code :
[language=]
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
using Ranorex.Core.Data;
. . . . . . . . . . . . . . . . . . .
string _Compte = "508007848017899";
[TestVariable("f78fcabb-3db8-4c5b-8a4e-1315e30a60a0")]
public string Compte
{
get { return _Compte; }
set { _Compte = value; }
}
string _Nom = "Qsdfgerty";
[TestVariable("f9975a38-a288-4399-82a7-1facbed5ed54")]
public string Nom
{
get { return _Nom; }
set { _Nom = value; }
}
void ITestModule.Run()
{
string query = "PostgreSQL";
string newQueryString = string.Format("SELECT dos.code FROM watt2.dossier dos JOIN watt2.document doc on dos.documentgenerateur_id = doc.id WHERE numcot = {0} AND nomsal = '{1}' ", _Compte, _Nom);
DataCache dc = DataSources.Get(query);
((SqlDataConnector) dc.Connector).Query = newQueryString; // having at this line
dc.Load();
}[/language]
But I'm having error : " La référence d'objet n'est pas définie à une instance d'un objet. " (sorry for no translation)
Here I'm trying to retrieve data from Excell and put them in variables "_Compte" and "_Nom" then execute query.
Hope you can help me,
Regards.
How to make our own queries with variables retrieved from Excell
Re: How to make our own queries with variables retrieved from Excell
Hi!
are you sure your DataConnector is named "PostgreSQL"?
For the example below ... ... you would have to use "DYN_TestEnv" as Name like:
BTW, you may want to consider to use the code block (button </> ) when posting code. Makes it easier to read in my eyes.
Hope it helps.
are you sure your DataConnector is named "PostgreSQL"?
For the example below ... ... you would have to use "DYN_TestEnv" as Name like:
Code: Select all
DataCache dc = DataSources.Get("DYN_TestEnv");
Hope it helps.
You do not have the required permissions to view the files attached to this post.