The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Hello there.
Is there a sample code that connects to a remote SQL database server?
(ADO.NET, ODBC, etc etc)

 
#2
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Hi.

Here is example:

Code
Connection = New COMObject("ADODB.Connection"); 
Connection.Open("DRIVER={SQL Server};SERVER=...;DATABASE=...;USER=...;PASSWORD=...");

RS = New COMObject("ADODB.Recordset"); 
RS.ActiveConnection = Connection;
RS.Open("SELECT * FR OM BANKS");
RS.MoveFirst(); 
While RS.EOF() = 0 Do
    Name = RS.Fields("NAME").Value;
    Message(Name);
    RS.MoveNext();    
EndDo;
RS.Close();
Connection.Close();

Edited: Alexei Khatin - Jul 03, 2016 11:21 AM
 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Hi.
I want convert date to string?
How can i do it?


CStr(RS.Fields("RECDATE").Value) ???
Convert / Parse / ToString() ??

 
#4
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Hi.

There are several ways:

Code
StringValue = Format(DateValue, "DF='dd.MM.yyyy HH:mm:ss'");
StringValue = String(DateValue);
StringValue = "" + DateValue;


Also you can call the "Format String Wizard" from the context menu to create or edit a format string.

 
Subscribe
Users browsing this topic (guests: 2, registered: 0, hidden: 0)