Click here to Skip to main content
15,887,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to prevent HDD format with source. Pin
ShinHyun28-Jun-09 14:21
ShinHyun28-Jun-09 14:21 
GeneralRe: how to prevent HDD format with source. Pin
Michael Dunn28-Jun-09 15:18
sitebuilderMichael Dunn28-Jun-09 15:18 
GeneralRe: how to prevent HDD format with source. Pin
ShinHyun28-Jun-09 16:41
ShinHyun28-Jun-09 16:41 
GeneralRe: how to prevent HDD format with source. Pin
killabyte28-Jun-09 17:47
killabyte28-Jun-09 17:47 
GeneralRe: how to prevent HDD format with source. Pin
Michael Dunn28-Jun-09 18:17
sitebuilderMichael Dunn28-Jun-09 18:17 
GeneralRe: how to prevent HDD format with source. Pin
ShinHyun28-Jun-09 21:37
ShinHyun28-Jun-09 21:37 
GeneralRe: how to prevent HDD format with source. Pin
«_Superman_»28-Jun-09 22:21
professional«_Superman_»28-Jun-09 22:21 
QuestionADO API Problem. Pin
forexsurfr28-Jun-09 12:59
forexsurfr28-Jun-09 12:59 
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 <iostream>
#include <string>

#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);
//--------------------------------------------------------------------------------------------------------------------------------------------
//recordset->Open("INSERT INTO mytable VALUES ('Goodbye')",
//connection.GetInterfacePtr(), ADODB::adOpenForwardOnly,
//ADODB::adLockReadOnly, ADODB::adCmdText);
//--------------------------------------------------------------------------------------------------------------------------------------------
recordset->Open("SELECT * from Customers",
connection.GetInterfacePtr(),
ADODB::adOpenForwardOnly, ADODB::adLockReadOnly,
ADODB::adCmdText);
//--------------------------------------------------------------------------------------------------------------------------------------------
while(!recordset->ADOEOF)
{
_variant_t var;
var = recordset->Fields->GetItem(L"value")->GetValue();
std::cout << static_cast<char *>(_bstr_t(var.bstrVal))
<< std::endl;
recordset->MoveNext();
};
//--------------------------------------------------------------------------------------------------------------------------------------------
//recordset->Close();
//recordset->Open("DROP TABLE mytable", connection.GetInterfacePtr(),
//ADODB::adOpenForwardOnly, ADODB::adLockReadOnly,
//ADODB::adCmdText);
}
catch(_com_error &e)
{
std::cerr << ::outputashex(hr) << ":"
<< static_cast<char *>(e.Description());
}
catch(...)
{
std::cerr << "Unhandled Exception";
};

}
QuestionMemory leak due to waiting thread Pin
Still learning how to code28-Jun-09 9:21
Still learning how to code28-Jun-09 9:21 
AnswerRe: Memory leak due to waiting thread Pin
Joe Woodbury28-Jun-09 9:34
professionalJoe Woodbury28-Jun-09 9:34 
GeneralRe: Memory leak due to waiting thread Pin
Still learning how to code28-Jun-09 10:32
Still learning how to code28-Jun-09 10:32 
GeneralRe: Memory leak due to waiting thread Pin
Joe Woodbury28-Jun-09 11:18
professionalJoe Woodbury28-Jun-09 11:18 
GeneralRe: Memory leak due to waiting thread Pin
Still learning how to code28-Jun-09 18:56
Still learning how to code28-Jun-09 18:56 
GeneralRe: Memory leak due to waiting thread Pin
Roger Stoltz28-Jun-09 21:58
Roger Stoltz28-Jun-09 21:58 
QuestionVertical scrollbar smooth scrolling in list control? Pin
Artz28-Jun-09 8:39
Artz28-Jun-09 8:39 
QuestionQt question Pin
alikalik28-Jun-09 8:30
alikalik28-Jun-09 8:30 
AnswerRe: Qt question Pin
Rajesh R Subramanian28-Jun-09 9:24
professionalRajesh R Subramanian28-Jun-09 9:24 
QuestionDLLRegisterServer failed with error code 0x80040200 Pin
zon_cpp27-Jun-09 22:37
zon_cpp27-Jun-09 22:37 
AnswerRe: DLLRegisterServer failed with error code 0x80040200 Pin
«_Superman_»27-Jun-09 23:36
professional«_Superman_»27-Jun-09 23:36 
GeneralRe: DLLRegisterServer failed with error code 0x80040200 Pin
zon_cpp28-Jun-09 19:17
zon_cpp28-Jun-09 19:17 
GeneralRe: DLLRegisterServer failed with error code 0x80040200 Pin
«_Superman_»28-Jun-09 22:15
professional«_Superman_»28-Jun-09 22:15 
GeneralRe: DLLRegisterServer failed with error code 0x80040200 Pin
zon_cpp28-Jun-09 22:36
zon_cpp28-Jun-09 22:36 
Questionhow to print create time of mail Pin
santhosh-padamatinti27-Jun-09 19:38
santhosh-padamatinti27-Jun-09 19:38 
Questionsetting font......... Pin
kumar sanghvi27-Jun-09 18:16
kumar sanghvi27-Jun-09 18:16 
Questiongood SQL to find a min valid user ID Pin
includeh1027-Jun-09 10:10
includeh1027-Jun-09 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.