Npgql get_HasRows() throwing ArgumentOutOfRangeException - postgresql

Good afternoon,
I`m currently developing with AspNetCore and MVC and using PostgreSQL (Npgsql) as my database.
My queries are working fine when they have some result.
When the query returns empty results, I got an ArgumentOutOfRangeException error.
System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: Got unexpected message type: ReadyForQuery
in Npgsql.NpgsqlDataReader.get_HasRows()
in QueryPostgreSQL.IsEmpty()
in sistema_cotacao.Controllers.LoginController.<Index>d__2.MoveNext() in \Visual Studio 2015\Projects\sistema-cotacao\src\sistema-cotacao\Controllers\LoginController.cs:line 66
This is the code where the error occurs (At query.IsEmpty()):
if ((query.IsEmpty()) || (usuario.enti_email != usu.enti_email))
{
...
query.Close();
return View();
}
else
{
....
query.close();
return Redirect("/Login");
}
And my IsEmpty() function is:
private NpgsqlDataReader queryPostgreSQL;
...
public Boolean IsEmpty()
{
Boolean bResult = true;
bResult = !queryPostgreSQL.HasRows;
return bResult;
}
I couldn`t find where my problem is.

This is a bug in Npgsql. The issue has been fixed and will be released in version 3.1.7 (probably later today).

Related

IArtifactRepositoryManager is null with Eclipse Oxygen 4.7.2

The following function worked perfectly in Eclipse Neon 4.6.x target runtime for a very long time:
public static boolean addRepository(IProvisioningAgent agent, String repo) {
Utils.log(String.format("adding repository at %s", repo));
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (metadataManager == null || artifactManager == null) {
Utils.log("P2Utils.addRepository - missing metadata or artifact manager");
return false;
}
try {
URI uri = new URI(repo);
metadataManager.addRepository(uri);
artifactManager.addRepository(uri);
return true;
} catch (Exception e) {
Utils.log(e);
return false;
}
}
It stopped working with Eclipse Oxygen 4.7.2 target, the artifactManager returned is always null. Does anyone involved knows what was changed and how to fix this? It breaks our updates.., I am at a loss where to look.
Got the response from eclipse forum, there were some plugins missing:
org.eclipse.equinox.p2.artifact.repository
org.eclipse.equinox.p2.transport.ecf

DotConnect PostgreSQL Update Command

string finalResult = "Failed";
using (PgSqlConnection myConnect = new PgSqlConnection(Resources.MyResources.DotConnectNewConnectionString))
{
try
{
myConnect.Open();
using (PgSqlCommand cmd = new PgSqlCommand("UPDATE salesforce.ent_inbound_correspondence_entity__c SET status__c = :status, status_change_date__c = CAST(:currentDate AS Date) WHERE deal_id__c = :projID AND correspondence_type__c= :cortype", myConnect))
{
cmd.Parameters.AddWithValue("status", status);
cmd.Parameters.AddWithValue("currentDate", DateTime.Now.ToString("yyyy-MM-dd"));
cmd.Parameters.AddWithValue("projID", projectID);
cmd.Parameters.AddWithValue("cortype", "704(b) Model");
int result = cmd.ExecuteNonQuery();
if (result > 0)
{
finalResult = "Success";
}
}
}
catch (PgSqlException ex)
{
throw ex;
}
finally
{
myConnect.Close();
}
}
return finalResult;
Hi All,
I am currently facing an issue when it comes to running an UPDATE query using DotConnect and PgSqlCommand. There are no exceptions occuring BUT whenever this is ran, cmd.ExecuteNonQuery() returns me 0. However, when I execute this query using 'absolute' values in PgAdmin, it has no issues at all.
Can anybody enlighten me on what is wrong with this piece of code? :(
Thank you!
EDIT: An exception message occurs with the following message: Message = "function get_xmlbinary() does not exist"
However, this function is not coded by me. I have no idea what this means.

Eclipse plugin - getting the IStackframe object from a selection in DebugView

So, this is the problem I am stuck at for a few weeks.
I am developing an Eclipse plugin which fills in a View with custom values depending on a particular StackFrame selection in the Debug View.
In particular, I want to listen to the stackframe selected and would like to get the underlying IStackFrame object.
However, I have tried more than a dozen things and all of them have failed. So I tried adding DebugContextListener to get the DebugContextEvent and finally the selection. However, the main issue is that ISelection doesn't return the underlying IStackFrame object. It instead returns an object of type AbstractDMVMNode.DMVMContext. I tried getting an adapter but that didn't work out too. I posted this question sometime back also:
Eclipse Plugin Dev- Extracting IStackFrame object from selection in Debug View
Since then, I have tried out many different approaches. I tried adding IDebugEventSetListener (but this failed as it cannot identify stack frame selection in the debug view).
I tried adding an object contribution action but this too was pointless as it ultimately returned me an ISelection which is useless as it only returns me an object of class AbstractDMVMNode.DMVMContext and not IStackframe.
Moreover, I checked out the implementation of the VariablesView source code itself in the org.eclipse.debug.ui plugin. It looks like a few versions back (VariablesView source code in version 3.2), the underlying logic was to use the ISelection and get the IStackFrame. All the other resources on the internet also advocate the same. However, now, this scheme no longer works as ISelection doesn't return you an IStackFrame. Also, the source code for the latest eclipse Debug plugin (which doesn't use this scheme) was not very intuitive for me.
Can anyone tell how I should proceed ? Is hacking the latest Eclipse source code for VariablesView my only option ? This doesn't look like a good design practice and I believe there should be a much more elegant way of doing this.
PS: I have tried all the techniques and all of them return an ISelection. So, if your approach too return the same thing, then it is most likely incorrect.
Edit (Code snippet for trying to adapt the ISelection):
// Following is the listener implemnetation
IDebugContextListener flistener = new IDebugContextListener() {
#Override
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
contextActivated(event.getContext());
}
};
};
// Few things I tried in the contextActivated Method
//Attempt 1 (Getting the Adapter):
private void contextActivated(ISelection context) {
if (context instanceof StructuredSelection) {
Object data = ((StructuredSelection) context).getFirstElement();
if( data instanceof IAdaptable){
System.out.println("check1");
IStackFrame model = (IStackFrame)((IAdaptable)data).getAdapter(IStackFrame.class);
if(model != null){
System.out.println("success" + model.getName());
}
}
}
}
// Attemp2 (Directly getting it from ISelection):
private void contextActivated(ISelection context) {
if (context instanceof StructuredSelection) {
System.out.println("a");
Object data = ((StructuredSelection) context).getFirstElement();
if (data instanceof IStackFrame) {
System.out.println("yes");
} else {
System.out.println("no" + data.getClass().getName());
}
}
// This always execute the else and it prints: org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMNode.DMVMContext
}
// Attemp3 (Trying to obtain it from the viewer (similiar to object action binding in some ways):
private void contextActivated(ISelection context) {
VariablesView variablesView = (VariablesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_VARIABLE_VIEW);
if (variablesView != null) {
Object input = ((TreeViewer) variablesView.getViewer()).getInput();
if(input != null) System.out.println(input.getClass().getName());
if (input instanceof IStackFrame) {
System.out.println("success");
} else if (input instanceof IThread) {
System.out.println("success");
try {
IStackFrame[] stackFrames = ((IThread) input).getStackFrames();
for (IStackFrame iStackFrame : stackFrames) {
printVariables(iStackFrame);
}
} catch (DebugException e) {
e.printStackTrace();
}
}
}
}
While I am building this view to work with both JDT & CDT, I am testing it out on the C project. So, this might be the reason why I always get the returned object type as AbstractDMVMNode.DMVMContext. Should my implementation be different to handle both these cases ? I believe I should be building a generic view. Also, if AbstractDMVMNode.DMVMContext is CDT specific, I should I go about implementing it for the CDT case?

Random "404 Not Found" error on PasrseObject SaveAsynch (on Unity/Win)

I started using Parse on Unity for a windows desktop game.
I save very simple objects in a very simple way.
Unfortunately, 10% of the time, i randomly get a 404 error on the SaveAsynch method :-(
This happen on different kind of ParseObject.
I also isolated the run context to avoid any external interference.
I checked the object id when this error happen and everything looks ok.
The strange thing is that 90% of the time, i save these objects without an error (during the same application run).
Did someone already got this problem ?
Just in case, here is my code (but there is nothing special i think):
{
encodedContent = Convert.ToBase64String(ZipHelper.CompressString(jsonDocument));
mLoadedParseObject[key]["encodedContent "] = encodedContent ;
mLoadedParseObject[key].SaveAsync().ContinueWith(OnTaskEnd);
}
....
void OnTaskEnd(Task task)
{
if (task.IsFaulted || task.IsCanceled)
OnTaskError(task); // print error ....
else
mState = States.SUCEEDED;
}
private void DoTest()
{
StartCoroutine(DoTestAsync());
}
private IEnumerator DoTestAsync()
{
yield return 1;
Terminal.Log("Starting 404 Test");
var obj = new ParseObject("Test1");
obj["encodedContent"] = "Hello World";
Terminal.Log("Saving");
obj.SaveAsync().ContinueWith(OnTaskEnd);
}
private void OnTaskEnd(Task task)
{
if (task.IsFaulted || task.IsCanceled)
Terminal.LogError(task.Exception.Message);
else
Terminal.LogSuccess("Thank You !");
}
Was not able to replicate. I got a Thank You. Could you try updating your Parse SDK.
EDIT
404 could be due to a bad username / password match. The exception messages are not the best.

Why is Assert.AreEqual failing in NUnit?

"Robert" exists in the NWind database. The following C# code fails in NUnit:
public void Robert_exists()
{
EmployeeBO empl = new EmployeeBO();
Boolean result = empl.DoesEmployeeRecordExists("Robert");
Assert.AreEqual(true, result);
}
But single stepping shows that "result" is "true"
I would be grateful for any advice.
If it is debugging that result is true, then this should work. However, as a test, you can try using the Assert.IsTrue(result); method?