ado

Using sql-server datetime2 with TADOQuery.open

六眼飞鱼酱① 提交于 2021-01-27 11:44:42
问题 I want to start using datetime2 fields in SQL Server and I need to insert into the tables via ADO from Delphi XE5. I am using TADOQuery.ExecSQL to insert and everything works fine. However most of my tables have identity columns, e.g. id integer identity(1,1) not null To save round-trips to the server, I usually use Open with two commands in the query text. The first command is the insert the second command is "select scope_identity() as scope_id" so I can retrieve the newly inserted id in

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

荒凉一梦 提交于 2021-01-27 06:45:38
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

放肆的年华 提交于 2021-01-27 06:44:25
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to

Load aggregate data from Excel into ADODB.RecordSet

两盒软妹~` 提交于 2020-12-15 06:25:12
问题 I am trying to load data from an Excel file in a specific sheet into an ADODB.RecordSet via a VBA macro by using SQL SELECT command. There are several columns on the Excel sheet, and I don't need all of them. For example: col.A = Surname, col.B = Name, col.C = IDPerson, [....columns that are not needed], Col.N = Boss The purpose would be to get a recordset of aggregated data for: col.C = IDPerson, col.N = Boss. The fields highlighted in the image below. I would like to have a RecordSet with

How to SELECT column which field name contains a dot

我怕爱的太早我们不能终老 提交于 2020-11-29 09:26:08
问题 I am using ADO to import data from Excel workbooks. I'm having some troubles with one worksheets where one column name contains a dot : "Col.1". I tried everything I found : double quotes, brackets, backstick. Nothing works. Either an error is raised or the query output "Col.1" on every row. QUERY_SQL = _ "SELECT `Col.1`, Col3 FROM [table$] " & _ "IN '" & SourcePath & "' " & CHAINE_HDR Given the fact that I can't rename the column in the source file, How can I manually select this column

How to retrieve all errors and messages from a query using ADO

最后都变了- 提交于 2020-08-23 06:57:22
问题 When a SQL batch returns more than one message from e.g. print statements, then I can only retrieve the first one using the ADO connection's Errors collection. How do I get the rest of the messages? If I run this script: Option Explicit Dim conn Set conn = CreateObject("ADODB.Connection") conn.Provider = "SQLOLEDB" conn.ConnectionString = "Data Source=(local);Integrated Security=SSPI;Initial Catalog=Master" conn.Open conn.Execute("print 'Foo'" & vbCrLf & "print 'Bar'" & vbCrLf & "raiserror (

How to retrieve all errors and messages from a query using ADO

爱⌒轻易说出口 提交于 2020-08-23 06:57:05
问题 When a SQL batch returns more than one message from e.g. print statements, then I can only retrieve the first one using the ADO connection's Errors collection. How do I get the rest of the messages? If I run this script: Option Explicit Dim conn Set conn = CreateObject("ADODB.Connection") conn.Provider = "SQLOLEDB" conn.ConnectionString = "Data Source=(local);Integrated Security=SSPI;Initial Catalog=Master" conn.Open conn.Execute("print 'Foo'" & vbCrLf & "print 'Bar'" & vbCrLf & "raiserror (