Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Connect another database server / read data

Forum

Search UsersRules
Connect another database server / read data
#1
Active user
Points:: 0
Joined:: Feb 26, 2015

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

Profile
#2
Active user
Points:: 0
Joined:: Apr 18, 2012

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();

Profile
#3
Active user
Points:: 0
Joined:: Feb 26, 2015

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


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

Profile
#4
Active user
Points:: 0
Joined:: Apr 18, 2012

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.

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



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.