mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Update db.js
This commit is contained in:
parent
9e50484063
commit
f5471e0bfb
16
lib/db.js
16
lib/db.js
|
@ -18,7 +18,7 @@ scope.open = function(cs) {
|
|||
try {
|
||||
instance.Connection = LIB.CreateObject("ADODB.Connection");
|
||||
} catch (e) {
|
||||
DBG("Failed to create ADODB.Connection, error = " + e.number + ", " + e.description);
|
||||
console.log("Failed to create ADODB.Connection, error = " + e.number + ", " + e.description);
|
||||
return;
|
||||
}
|
||||
instance.ConnectionString = cs;
|
||||
|
@ -42,7 +42,7 @@ scope.open = function(cs) {
|
|||
var RS = LIB.CreateObject("ADODB.Recordset");
|
||||
RS.LockType = 1; // adLockReadOnly
|
||||
RS.CursorType = 1; // adOpenKeySet
|
||||
DBG("> " + sql);
|
||||
console.log("> " + sql);
|
||||
RS.Open(sql, instance.Connection);
|
||||
return RS;
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ scope.open = function(cs) {
|
|||
// instance.exec
|
||||
// Run a statement (update or insert) and return true if successful
|
||||
instance.exec = function(sql) {
|
||||
DBG("> " + sql);
|
||||
console.log("> " + sql);
|
||||
var ok;
|
||||
try {
|
||||
ok = instance.Connection.Execute(sql);
|
||||
|
@ -63,7 +63,7 @@ scope.open = function(cs) {
|
|||
};
|
||||
|
||||
instance.insert = function(table, columns) {
|
||||
DBG("> insert into " + table + " some data!");
|
||||
console.log("> insert into " + table + " some data!");
|
||||
var RS = LIB.CreateObject("ADODB.Recordset");
|
||||
RS.open(table, instance.Connection, 2, 3, 2);
|
||||
RS.addNew();
|
||||
|
@ -87,9 +87,9 @@ scope.blob2Text = function(blobField, charset) {
|
|||
stream.Charset = (charset || "us-ascii").replace(/;$/, "");
|
||||
stream.Type = 1;
|
||||
stream.Open();
|
||||
DBG("WRITE STREAM");
|
||||
console.log("WRITE STREAM");
|
||||
stream.Write(blobField);
|
||||
DBG("DONE WRITE STREAM");
|
||||
console.log("DONE WRITE STREAM");
|
||||
stream.Position = 0;
|
||||
stream.Type = 2;
|
||||
var text = stream.ReadText(-1);
|
||||
|
@ -108,7 +108,7 @@ scope.saveBlob = function(filename, blobField) {
|
|||
stream.Close();
|
||||
return true;
|
||||
} catch (e) {
|
||||
DBG("ERROR " + e.number + " saving blob: " + e.description);
|
||||
console.log("ERROR " + e.number + " saving blob: " + e.description);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -116,4 +116,4 @@ scope.quoteString = function(s) {
|
|||
return "'" + s.replace(/\'/g, "''") + "'";
|
||||
};
|
||||
|
||||
return scope;
|
||||
return scope;
|
||||
|
|
Loading…
Reference in New Issue
Block a user