Browsing 15711 questions and answers with Jon Skeet

Avoiding skipping a row By next() Method of ResultSet

This is a simple code print some rows from a Database. but When I execute this nothing is print on screen. I figured that the problem is rs.next() method is skipping a row. So How...
Jon Skeet
people
quotationmark

First, stop building SQL like that - use parameterized SQL and a PreparedStatement. Your current code is vulnerable to SQL injection attacks. Basically, don't call rs.next() twice in a row (first in the if then in the while)... you can... more 5/20/2017 4:18:16 PM

people

.NET Standard vs .NET Core

I have read about the difference between .NET Standard and .NET Core but really I don't know what the difference is, or when to choose a .NET Standard library project and when to...
Jon Skeet
people
quotationmark

.NET Core is an implementation of .NET Standard. It's available on multiple operating systems, but that's not the same thing - there are other implementations of .NET Standard as well. So if you create a .NET Core library, it will have... more 5/20/2017 11:41:26 AM

people

Unchecked assignment for 'java.util.ArrayList'

I get the warning: Unchecked assignment for 'java.util.ArrayList' to 'java.util.ArrayList < com.test.mytest ' for: private ArrayList<LocoList> myLocations = new...
Jon Skeet
people
quotationmark

You want new ArrayList<>(); so that you use the right generic type. At the moment you're using the raw type on the right hand side of =. So you want: private ArrayList<LocoList> myLocations = new ArrayList<>(); Or just... more 5/19/2017 8:00:08 PM

people

MSBuildWorkspace Get Embedded Resource Files

I'm trying to get out all embedded resource files from a solution using Roslyn and MSBuild Api. private async Task<Document> CheckConstForLocalization(Document document,...
Jon Skeet
people
quotationmark

You can't, at the moment. It isn't supported by the API. (I was researching this just yesterday.) There's a feature request to support it which you might like to support and subscribe to, but I don't believe there's any way of doing this... more 5/19/2017 7:45:36 PM

people

C# Array Within Array of Structs Losing Contents

I'm just returning back to C# after an extended period of C++ and Qt. I'm currently stumped by what I would have thought to be a very simple problem. I have a struct: struct...
Jon Skeet
people
quotationmark

It had occurred to me that the struct was being passed into the RenderFontGlyph function by-value rather than by-ref but this also makes no difference! Well yes, it does. You're creating a copy of the struct, and passing that into... more 5/19/2017 7:08:28 PM

people

Constructor Enum error

public enum ProductCategory { FOOD, BEVERAGE, DEFAULT; private final String label; private ProductCategory(String label){ this.label = label; } public String getLabel(){ ...
Jon Skeet
people
quotationmark

The only constructor you've currently got requires a string to be passed in - but all the enum values (FOOD, BEVERAGE, DEFAULT) don't specify strings, so they can't call the constructor. Two options: Add a parameterless... more 5/19/2017 5:18:51 PM

people

Java number precision in Javascript

I have the following code in Java that convert Hex values to Long numbers, in the example I used the value: 'B4EEB49B04C0' public static long HexStr2Long(String value) { ...
Jon Skeet
people
quotationmark

1463925582232864000 is the nearest 64-bit IEEE-754 floating point number to 1463925582232863984. Numbers in Javascript are (at the moment - I believe this is changing) always 64-bit IEEE-754 floating point numbers. Basically, in order to... more 5/18/2017 4:03:51 PM

people

Date difference from Noda Time is correct?

DateTime dtStart = new DateTime(2015,7,28); LocalDate ldtStart = LocalDate.FromDateTime(dtStart); DateTime dtEnd = new DateTime(2017, 2, 1); LocalDate ldtEnd =...
Jon Skeet
people
quotationmark

"More accurate" requires a specification of how you want to compute the difference. There's no single right answer here. As documented, Noda Time works element-wise. So if you add 1 year, 6 months and 4 days to 28th July 2015 you... more 5/18/2017 5:57:24 AM

people

Can't seem to change properties of objects in winforms C#

This is a bit of a confusing scenario. Basically, I'm trying to set a button's color when I use setter for a private variable that I store its color in. First off, I have a...
Jon Skeet
people
quotationmark

Did I do something wrong? Yes. Your setter is just fetching the existing property value: this.btn_input.BackColor = buttonColor; this._buttonColor = buttonColor; You meant to use value, which is the implicit parameter name for the... more 5/17/2017 6:13:04 PM

people

Cannot convert dbconnection to sqlconnection

I have created a generic method which will work with all database like sql server,mysql and oracle and execute my sql query and return datatable. private Datatable GetData(string...
Jon Skeet
people
quotationmark

Basically, when you call new SqlCommand(), that will only work with a SqlConnection. It's not going to work for MySqlConnection, or for anything from Oracle etc. SqlCommand is tightly coupled to SqlConnection. So either you need a... more 5/16/2017 12:35:05 PM

people