SQL Server r2--vc++ ADO operations

Source: Internet
Author: User
Tags ole

================================== Declaration ==================================

This article is original, reproduced in the text of the influential annotated author and source, and to ensure the integrity of the article.

Do not modify (including this statement) without the consent of the author, and reserve the right of legal investigation.

Do not use for publication, printing or academic reference without the consent of the author.

In order to ensure the correct contents, we suggest that we should read the original text.

This article link: http://www.cnblogs.com/wlsandwho/p/4352764.html

=======================================================================

does not contain any error handling and exception handling, write-only critical code.

=======================================================================

The database used for testing

TestDB

Login name and password for testing

Testdev

123456

Contents of the Sqlserver_ed.udl file for testing

1 [OLE DB] 2  This  is An OLE DB initstring 3 provider=sqloledb. 1; password=123456; Persist Security info=true; User id=testdev;initial Catalog=testdb;data source=thbytwo-pc-test\sqlexpress

=======================================================================

A table for testing

CREATE TABLE  testtable (id   int null,val int NULL)

Stored procedures for testing

1CREATEproc proc_testproc  @id  @val int2 as 3 insert into Dbo.testtable4  (ID, Val) 5  @id, -- Id-int6  @val -- Val-int7)       

=======================================================================

Simple connect and insert operations using only connection objects.

1 CoInitialize (NULL);2 3 _connectionptr pconnection;4Pconnection.createinstance (TEXT ("ADODB. Connection"));5 6Pconnection->connectionstring=text ("File name=sqlserver_ed.udl");7pconnection->commandtimeout=Ten;8pconnection->cursorlocation=adUseClient;9Pconnection->mode=adModeUnknown;TenPconnection->open (TEXT (""), TEXT (""), TEXT (""), adconnectunspecified); One  A CString Strinsert; -Strinsert.format (TEXT ("Insert into testtable values (%d,%d)"),5,6); -  thePconnection->Execute (_bstr_t (Strinsert), null,adcmdtext); -  -Pconnection->Close (); -pconnection-. Release ();  +  -CoUninitialize ();

Using stored procedures with parameters for the same insert operation

To eat.

SQL Server r2--vc++ ADO operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.