Here is an example:
var accountGuid;
accountGuid = document.getElementById("your fieldname here");
if (IsOnline())
{
// write code for online version here.
}
else
{
var iCount = 0;
var connection = new ActiveXObject("ADODB.Connection");
var connectionString = "Provider=SQLOLEDB;Server=.\\CRM;Database=MSCRM_MSDE;Integrated Security=sspi";
connection.Open(connectionString);
var query = "SELECT count(*) FROM AccountBase WHERE AccountID='" + accountGuid.value + "'";
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open(query, connection, /*adOpenKeyset*/1, /*adLockPessimistic*/2);
rs.moveFirst();
while (!rs.eof) {
iCount = rs.Fields(0).Value;
rs.moveNext();
}
connection.Close();
if (iCount > 0 ) {
//do something useful here
}
else {
//do something else here
}
}
No comments:
Post a Comment