add better null handling on dates and excpetion handling on sql calls
This commit is contained in:
parent
489823eb0c
commit
855add36cf
26
runner.cs
26
runner.cs
@ -77,11 +77,11 @@ namespace test
|
|||||||
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
||||||
break;
|
break;
|
||||||
case "DATE":
|
case "DATE":
|
||||||
if (getv[i].ToString() != "1/1/0001 12:00:00 AM") {
|
if (getv[i].ToString() == "1/1/0001 12:00:00 AM" || getv[i].ToString() == "") {
|
||||||
nc = "'" + getv[i].ToString() + "'";
|
nc = "NULL";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nc = "NULL";
|
nc = "'" + getv[i].ToString() + "'";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "TIME":
|
case "TIME":
|
||||||
@ -117,7 +117,15 @@ namespace test
|
|||||||
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
|
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
|
||||||
pgcom.CommandText = sql;
|
pgcom.CommandText = sql;
|
||||||
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
|
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
|
||||||
pgcom.ExecuteNonQuery();
|
try {
|
||||||
|
pgcom.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Console.Write(Environment.NewLine);
|
||||||
|
Console.Write(e.Message);
|
||||||
|
ibmc.Close();
|
||||||
|
pgc.Close();
|
||||||
|
}
|
||||||
sql = "";
|
sql = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +133,15 @@ namespace test
|
|||||||
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
|
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
|
||||||
pgcom.CommandText = sql;
|
pgcom.CommandText = sql;
|
||||||
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
|
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
|
||||||
pgcom.ExecuteNonQuery();
|
try {
|
||||||
|
pgcom.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Console.Write(Environment.NewLine);
|
||||||
|
Console.Write(e.Message);
|
||||||
|
ibmc.Close();
|
||||||
|
pgc.Close();
|
||||||
|
}
|
||||||
sql = "";
|
sql = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user