function BOOL ExecuteSQL(sSQL, sServerName, sDBName, sDriver, bTrustedConn, sUserName, sUserPwd, bLog, bQuery) OBJECT objConn, objRST, pADORecordSetObj,adoCommand; STRING sTekst, sConnString; STRING szADOConnObjID,szADORecordSetObjID; STRING szError; BOOL bReturn; begin bReturn = FALSE; // Create the connectionstring if (sDriver == "") then sConnString = "Provider=sqloledb;"; else sConnString = "Driver={" + sDriver + "};"; endif; if (bTrustedConn) then //ACA_Log_AppendLine(" using Windows Authentication"); sConnString = sConnString + "server=" + sServerName + ";"; sConnString = sConnString + "database=" + sDBName + ";"; sConnString = sConnString + "Trusted_connection=Yes"; else //ACA_Log_AppendLine(" using SQL Login"); sConnString = sConnString + "server=" + sServerName + ";"; sConnString = sConnString + "uid=" + sUserName + ";"; sConnString = sConnString + "pwd=" + sUserPwd + ";"; sConnString = sConnString + "database=" + sDBName; endif; try szADOConnObjID = "ADODB.Connection"; set objConn = CreateObject(szADOConnObjID); if (IsObject(objConn)) then objConn.ConnectionString = sConnString; objConn.Open; if (!bQuery) then //Jeżeli to Execute SQL a nie Query set objRST = objConn.Execute(sSQL); bReturn = TRUE; else // Create ADO Recordset object for the return szADORecordSetObjID = "ADODB.Recordset"; set pADORecordSetObj = CreateObject(szADORecordSetObjID); pADORecordSetObj.CursorType = 3; pADORecordSetObj.ActiveConnection = objConn; pADORecordSetObj.Open(sSQL); if ((pADORecordSetObj.RecordCount >= 1)||(pADORecordSetObj.RecordCount = -1)) then bReturn = TRUE; else bReturn = FALSE; endif; set pADORecordSetObj = NOTHING; endif; else if (bLog) then WriteLog(1,"Nie moża utworzyć obiektu połączenia ADODB.Connection do "+sDBName); endif; endif; set objConn = NOTHING; set objRST = NOTHING; catch if (bLog) then WriteLog(1,"Błąd wykonania zapytania SQL"); endif; endcatch; return (bReturn); end;
Programowanie c++/c#/delphi/javas/php/installscript/nativescript
Przykłady - przydatne funkcje
wtorek, 27 października 2009
ExecuteSQL
Wykonanie zapytania SQL lub procedury
Etykiety:
InstallShield - SQL
Subskrybuj:
Komentarze do posta (Atom)
Brak komentarzy:
Prześlij komentarz