mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-12-11 18:12:51 +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 {
|
try {
|
||||||
instance.Connection = LIB.CreateObject("ADODB.Connection");
|
instance.Connection = LIB.CreateObject("ADODB.Connection");
|
||||||
} catch (e) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
instance.ConnectionString = cs;
|
instance.ConnectionString = cs;
|
||||||
|
|
@ -42,7 +42,7 @@ scope.open = function(cs) {
|
||||||
var RS = LIB.CreateObject("ADODB.Recordset");
|
var RS = LIB.CreateObject("ADODB.Recordset");
|
||||||
RS.LockType = 1; // adLockReadOnly
|
RS.LockType = 1; // adLockReadOnly
|
||||||
RS.CursorType = 1; // adOpenKeySet
|
RS.CursorType = 1; // adOpenKeySet
|
||||||
DBG("> " + sql);
|
console.log("> " + sql);
|
||||||
RS.Open(sql, instance.Connection);
|
RS.Open(sql, instance.Connection);
|
||||||
return RS;
|
return RS;
|
||||||
};
|
};
|
||||||
|
|
@ -50,7 +50,7 @@ scope.open = function(cs) {
|
||||||
// instance.exec
|
// instance.exec
|
||||||
// Run a statement (update or insert) and return true if successful
|
// Run a statement (update or insert) and return true if successful
|
||||||
instance.exec = function(sql) {
|
instance.exec = function(sql) {
|
||||||
DBG("> " + sql);
|
console.log("> " + sql);
|
||||||
var ok;
|
var ok;
|
||||||
try {
|
try {
|
||||||
ok = instance.Connection.Execute(sql);
|
ok = instance.Connection.Execute(sql);
|
||||||
|
|
@ -63,7 +63,7 @@ scope.open = function(cs) {
|
||||||
};
|
};
|
||||||
|
|
||||||
instance.insert = function(table, columns) {
|
instance.insert = function(table, columns) {
|
||||||
DBG("> insert into " + table + " some data!");
|
console.log("> insert into " + table + " some data!");
|
||||||
var RS = LIB.CreateObject("ADODB.Recordset");
|
var RS = LIB.CreateObject("ADODB.Recordset");
|
||||||
RS.open(table, instance.Connection, 2, 3, 2);
|
RS.open(table, instance.Connection, 2, 3, 2);
|
||||||
RS.addNew();
|
RS.addNew();
|
||||||
|
|
@ -87,9 +87,9 @@ scope.blob2Text = function(blobField, charset) {
|
||||||
stream.Charset = (charset || "us-ascii").replace(/;$/, "");
|
stream.Charset = (charset || "us-ascii").replace(/;$/, "");
|
||||||
stream.Type = 1;
|
stream.Type = 1;
|
||||||
stream.Open();
|
stream.Open();
|
||||||
DBG("WRITE STREAM");
|
console.log("WRITE STREAM");
|
||||||
stream.Write(blobField);
|
stream.Write(blobField);
|
||||||
DBG("DONE WRITE STREAM");
|
console.log("DONE WRITE STREAM");
|
||||||
stream.Position = 0;
|
stream.Position = 0;
|
||||||
stream.Type = 2;
|
stream.Type = 2;
|
||||||
var text = stream.ReadText(-1);
|
var text = stream.ReadText(-1);
|
||||||
|
|
@ -108,7 +108,7 @@ scope.saveBlob = function(filename, blobField) {
|
||||||
stream.Close();
|
stream.Close();
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} 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 "'" + s.replace(/\'/g, "''") + "'";
|
||||||
};
|
};
|
||||||
|
|
||||||
return scope;
|
return scope;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user