Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jopp289/domains/progmans.net/public_html/engine/modules/show.short.php on line 160 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jopp289/domains/progmans.net/public_html/engine/modules/show.short.php on line 160 Connection » Шпаргалки
Заголовок



Server = "ServerName";    //Имя сервера
DataBase = "DBName";      //Имя базы данных
Login = "sa";                      //Логин
Password = "secretpsw";   //Пароль
    
Connection = CreateObject("ADODB.Connection");
ConnectionString = "driver={SQL Server};"+"server="+СокрЛП(Server)+";"+"uid="+СокрЛП
              (Login)+"; "+"pwd="+СокрЛП(Password)+";"+"Database="+СокрЛП(Database);
Connection.ConnectionTimeOut = 600;
Connection.CommandTimeout = 300;
    
Connection.Open(ConnectionString);

Payments = CreateObject("ADODB.RecordSet");
Payments.ActiveConnection = Connection;
    
strQuery = "
          |    SELECT Field1, Field2
          |    FROM Payments    
          |";
    
Payments.Open(strQuery);

While Payments.EOF = 0 Do
          Сообщить(Payments.Fields("Field1").Value);
          Сообщить(Payments.Fields("Field2").Value);
          Payments.MoveNext();
EndDo;
    
Payments.Close();
ПустоеЗначение(Payments);
Connection.Close();
ПустоеЗначение(Connection);



sql - запрос к базе данных
cn - соединение с базой данных (ADODB.connection)
rcd - рекордсет (ADODB.Recordset)


sql = ""
sql = "SELECT * FROM dbTableName"
rcd.Open sql, cn, adOpenStatic

rcd.MoveFirst
While Not rcd.EOF
    MsgBox rcd("TableFieldValue")
    rcd.MoveNext
Wend