Can Visual Studio target earlier C# syntax in addition to earlier .NET framework versions?
Tag : chash , By : user86493
Date : March 29 2020, 07:55 AM
will help you This can be done by specifying the language version in the project settings. To set the language version to C# 2.0 do the following Right Click on the project and select "Properties" Go to the "Build" Tab Click the "Advanced" Button Change the "Language Version" drop down to "ISO-2"
|
Don't Update If There Is Data Earlier
Date : March 29 2020, 07:55 AM
around this issue pst.setBinaryStream(4, rst.getBinaryStream(1), (int) rst.getString(1).length()); did the trick.
|
listview - my new inserted data is replacing earlier data
Date : March 29 2020, 07:55 AM
like below fixes the issue i found that answer from @ling.s was right. but it need some finishing touched. i try to make Globals.java. this is the code public class Globals {
public static ArrayList<HashMap<String, String>> mylist;
if (Globals.mylist == null)
Globals.mylist = new ArrayList<HashMap<String, String>>();
Bundle bun = null;
try{
bun = EntryTO.this.getIntent().getExtras();
id = bun.getLong("id");
brand = bun.getString("brand");
qty = bun.getString("qty");
map1 = new HashMap<String, String>();
if (Globals.mylist.size() == 0) {
map1.put("one", brand);
map1.put("two", qty);
Globals.mylist.add(map1);
}else {
int j=Globals.mylist.size();
map1.put("one", brand);
map1.put("two", qty);
Globals.mylist.add(j,map1);
}
try {
adapter = new SimpleAdapter(EntryTO.this, Globals.mylist, R.layout.item_to,
new String[] {"one", "two" },
new int[] {R.id.edtbrandto, R.id.edtqtyto });
setListAdapter(adapter);
}catch (Exception e) {Toast.makeText(EntryTO.this, "Ada Error Exception", Toast.LENGTH_LONG).show();}
}catch(NullPointerException e){}
|
When i try to insert new value, the old value i inserted earlier gets updated. This is my code
Date : March 29 2020, 07:55 AM
hope this fix your issue I do not see any code here which does actual updating, unless you can clarify what you are seeing and what you expect to see the following may not help here. Right now you are deleting a table and recreating it, this will remove all previous data from it. Your Insert statement will typically never alter previous rows for which none exist so I am going to take a guess based on your question that you may have an Update Employee Set (New Data) which would alter the previous record. import pymysql
conn = pymysql.connect({Connection Data here})
cur = conn.cursor()
sql = """INSERT INTO EMPLOYEE(FIRST_NAME, LAST_NAME, AGE, SEX, SALARY) VALUES ('Nazaf', 'Anwar', 22, 'M', 10000)"""
try:
cur.execute(sql)
conn.commit()
except:
conn.rollback()
cur.execute("""SELECT * FROM employee;""")
#You should see the current data here.
sql = """INSERT INTO EMPLOYEE(FIRST_NAME, LAST_NAME, AGE, SEX, SALARY) VALUES ('John', 'Doe', 44, 'M', 300000)"""
cur.execute(sql)
cur.execute("""SELECT * FROM employee;""")
#You should see both Nazaf and John
sql = """UPDATE EMPLOYEE SET SALARY=30 WHERE FIRST_NAME='John'"""
cur.execute(sql)
cur.execute("""SELECT * FROM employee;""")
#You should see both Nazaf and John, however John's salary will be 30
sql = """UPDATE EMPLOYEE SET FIRST_NAME='BOB'"""
cur.execute(sql)
cur.execute("""SELECT * FROM employee;""")
#You should see the first names changed to bob.
print(cur.fetchall())
cur.close()
conn.close()
|
Determine if task is earlier while only knowing if date is earlier and if time is earlier
Date : March 29 2020, 07:55 AM
wish helps you Without equality comparison methods in your time classes, you will have to also do the reverse comparison using isEarlier to decide when to compare time fields. public boolean isEarlier(Task argTask) {
if(this.date.isEarlier(argTas.date)) {
return true;
} else if(argTask.date.isEarlier(this.date)) {
return false;
} else if(this.time.isEarlier(argTask.time)) { //reached if date fields are equal
return true;
}
//At this stage, either `argTask.time.isEarlier(this.time)` returns true
//or date and time in both objects are exactly equal
return false;
}
|