Code C# Sql Server
Posted: Wed Jul 31, 2019 5:15 am
O método ou a operação não está implementada.
Show/Hide Stacktrace
em MyTest9.Recording1.teste(String argument1) na D:\__IVAN\Documentos\Ranorex\RanorexStudio Projects\MyTest9\MyTest9\Recording1.UserCode.cs:linha 48em MyTest9.Recording1.Ranorex.Core.Testing.ITestModule.Run() na D:\__IVAN\Documentos\Ranorex\RanorexStudio Projects\MyTest9\MyTest9\Recording1.cs:linha 123em Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)
When i execute the code below, i receive the message above:
///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// Your custom recording code should go in this file.
// The designer will only add methods to this file, so your custom code won't be overwritten.
// http://www.ranorex.com
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Repository;
using Ranorex.Core.Testing;
namespace MyTest9
{
public partial class Recording1
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
// Your recording specific initialization code goes here.
}
public string teste(string argument1)
{
var conexao = string.Empty;
var query = string.Empty;
conexao = "Provider=sqloledb; Data Source=localhost" + "\" + SQLEXPRESS; Initial Catalog=ErpRanores; Integrated Security=SSPI; ";
query = "select produto from estoque";
argument1 = Validate_DatabaseFieldWithQuery(conexao, query);
// TODO: Replace the following line with your code implementation.
throw new NotImplementedException();
}
public string Validate_DatabaseFieldWithQuery(string OLEConnectionString, string SQLQuery)
{
// check is connection string is empty
if (string.IsNullOrEmpty(OLEConnectionString))
{
return "";
throw new Ranorex.RanorexException("ConnectionString is empty");
}
// check if SQL statement is empty
if (SQLQuery.Trim().Equals(string.Empty))
{
return "";
throw new Ranorex.RanorexException("SQLQuery is empty");
}
// establish connection to database
using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(@OLEConnectionString))
{
connection.Open();
System.Data.OleDb.OleDbCommand command = null;
System.Data.OleDb.OleDbDataReader SQLReader = null;
try
{
// set SQL statement and execute search
command = new System.Data.OleDb.OleDbCommand(SQLQuery, connection);
SQLReader = command.ExecuteReader();
SQLReader.Read();
// check if there is a result
if (SQLReader.HasRows)
{
// retrieve single result from SQL database
var actualValue = SQLReader.GetString(0);
var retorno = string.Empty;
// prepare log message
retorno = "Actual value = '{0}', expected value = '{1}' (database query = " + SQLQuery + ")";
return actualValue;
// compare retrieved value with expected value
Ranorex.Validate.AreEqual(OLEConnectionString, SQLQuery);
}
else
{
return "";
throw new Ranorex.RanorexException(string.Format("SQL statement did not return any results: {0}", SQLQuery));
}
}
finally
{
command.Dispose();
SQLReader.Dispose();
}
}
}
}
}
Show/Hide Stacktrace
em MyTest9.Recording1.teste(String argument1) na D:\__IVAN\Documentos\Ranorex\RanorexStudio Projects\MyTest9\MyTest9\Recording1.UserCode.cs:linha 48em MyTest9.Recording1.Ranorex.Core.Testing.ITestModule.Run() na D:\__IVAN\Documentos\Ranorex\RanorexStudio Projects\MyTest9\MyTest9\Recording1.cs:linha 123em Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)
When i execute the code below, i receive the message above:
///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// Your custom recording code should go in this file.
// The designer will only add methods to this file, so your custom code won't be overwritten.
// http://www.ranorex.com
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Repository;
using Ranorex.Core.Testing;
namespace MyTest9
{
public partial class Recording1
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
// Your recording specific initialization code goes here.
}
public string teste(string argument1)
{
var conexao = string.Empty;
var query = string.Empty;
conexao = "Provider=sqloledb; Data Source=localhost" + "\" + SQLEXPRESS; Initial Catalog=ErpRanores; Integrated Security=SSPI; ";
query = "select produto from estoque";
argument1 = Validate_DatabaseFieldWithQuery(conexao, query);
// TODO: Replace the following line with your code implementation.
throw new NotImplementedException();
}
public string Validate_DatabaseFieldWithQuery(string OLEConnectionString, string SQLQuery)
{
// check is connection string is empty
if (string.IsNullOrEmpty(OLEConnectionString))
{
return "";
throw new Ranorex.RanorexException("ConnectionString is empty");
}
// check if SQL statement is empty
if (SQLQuery.Trim().Equals(string.Empty))
{
return "";
throw new Ranorex.RanorexException("SQLQuery is empty");
}
// establish connection to database
using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(@OLEConnectionString))
{
connection.Open();
System.Data.OleDb.OleDbCommand command = null;
System.Data.OleDb.OleDbDataReader SQLReader = null;
try
{
// set SQL statement and execute search
command = new System.Data.OleDb.OleDbCommand(SQLQuery, connection);
SQLReader = command.ExecuteReader();
SQLReader.Read();
// check if there is a result
if (SQLReader.HasRows)
{
// retrieve single result from SQL database
var actualValue = SQLReader.GetString(0);
var retorno = string.Empty;
// prepare log message
retorno = "Actual value = '{0}', expected value = '{1}' (database query = " + SQLQuery + ")";
return actualValue;
// compare retrieved value with expected value
Ranorex.Validate.AreEqual(OLEConnectionString, SQLQuery);
}
else
{
return "";
throw new Ranorex.RanorexException(string.Format("SQL statement did not return any results: {0}", SQLQuery));
}
}
finally
{
command.Dispose();
SQLReader.Dispose();
}
}
}
}
}