Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

INSERT INTO SQL problem

bonosabonosa Member Posts: 6
I am doing:

pCommand->CommandText="INSERT INTO tblTest (Color, Texture) VALUES ('navy blue', 'rusty') ";
_RecordsetPtr pRecordset;

hr = pRecordset.CreateInstance (__uuidof (Recordset));

if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
AfxMessageBox("LLL");

pRecordset->CursorLocation = adUseClient;
pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenDynamic, adLockBatchOptimistic, adCmdTable);


I get an exception at the open statement....

Comments

  • gigsvoogigsvoo Member Posts: 328
    What is the exeception msg?

    [size=2]Neo Gigs[/size]
    [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]

  • SurSur Member Posts: 2
    Well this could be the answer to your problem...
    //
    HRESULT hr;
    _CommandPtr pCommand = NULL;
    _RecordsetPtr pRecordset;

    pCommand.CreateInstance(__uuidof(Command));
    pCommand->ActiveConnection = pConn; // attach your connection object here
    pCommand->CommandTimeout = 15;
    pCommand->CommandType = adCmdText;
    pCommand->CommandText="INSERT INTO TableName VALUES (1,'test') ";


    hr = pRecordset.CreateInstance (__uuidof (Recordset));

    if (FAILED (hr))
    {
    AfxMessageBox ("Can't create an instance of Recordset");
    return;
    }

    AfxMessageBox("LLL");

    pRecordset->CursorLocation = adUseClient;
    pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenDynamic, adLockBatchOptimistic, adCmdText);


    AfxMessageBox("Success");
    // end
    Enjoy...
  • Justin BibJustin Bib USAMember Posts: 0

    ___ [ http://forcoder.org ] free video tutorials and ebooks about \ Swift Perl Visual Basic Ruby Objective-C JavaScript Python PHP Assembly Visual Basic .NET Java MATLAB R Scratch Go C# Delphi PL/SQL C++ C D Scheme Transact-SQL Kotlin Dart Alice Hack Awk Julia F# COBOL Lua Logo VBScript Fortran Crystal Lisp Rust LabVIEW ML Clojure ABAP Bash SAS Apex Scala Prolog FoxPro Erlang Ada \ _____________

Sign In or Register to comment.