Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ADO API Problem.

ADO API Problem.

Scheduled Pinned Locked Moved C / C++ / MFC
databasesql-serverhelpsysadminjson
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    forexsurfr
    wrote on last edited by
    #1

    Can someone help me with the below ADO API? I am a new programmer and am having problems programming a SQL Server connection. I have found various connection strings and continue to run into problems with the syntax. Thank you in advance. #include "stdafx.h" #include #include #import "C:\Program files\Common Files\System\Ado\msado15.dll" rename("EOF", "ADOEOF") //--------------------------------------------------------------------------------------------------------------------------------------------- std::string outputashex(unsigned long l) { char buffer[1024]; ::itoa(l, buffer, 16); return buffer; } ; //--------------------------------------------------------------------------------------------------------------------------------------------- void main() { HRESULT hr; CoInitialize(NULL); try { ADODB::_ConnectionPtr connection; hr = connection.CreateInstance(__uuidof(ADODB::Connection)); if (FAILED(hr)) { throw _com_error(hr); } //-------------------------------------------------------------------------------------------------------------------------------------------- ADODB::_RecordsetPtr recordset; hr = recordset.CreateInstance(__uuidof(ADODB::Recordset)); if (FAILED(hr)) { throw _com_error(hr); } //-------------------------------------------------------------------------------------------------------------------------------------------- connection->CursorLocation = ADODB::adUseClient; //-------------------------------------------------------------------------------------------------------------------------------------------- connection->Open("Provider=sqloledb;Server=.\SQLExpress;AttachDbFilename=c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\WattsALoan.mdf;Database=WattsALoan;Trusted_Connection=Yes;") //------------------------------------------------------------------------------------------------------------------------------------------- //recordset->Open("CREATE TABLE mytable (value NVARCHAR(255))", //connection.GetInterfacePtr(), ADODB::adOpenForwardOnly, //ADODB::adLockReadOnly, ADODB::adCmdText); //-------------------------------------------------------------------------------------------------------------------------------------------- //recordset->Open("INSERT INTO mytable VALUES ('Hello')", //connection.GetInterfacePtr(), ADODB::adOpenForwardOnly, //ADODB::adLockReadOnly, ADODB::adCmdText); //-------------------------------------------------------------------------------------------------------------

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups