Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

ADO :: Adding Row, but changes not stored
After successfully creating a connection to an Access Database file on
my computer, I try to add a new row. Everything seems to go fine, but
when I open the file in Access, the row isn't there. I get no errors
or exceptions while running. In the code below, you can see I go back
and check if the data is in the table after I've added it, and it is.
Still, it's never stored permanently. Obviousy, I'm missing some
steps. Can anyone point me in the right direction?


m_dbConnection = gcnew OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;" +
"DataSource=" + szDataPath);

/* returns an empty dataset but with the correct structure */
sa->Fill( ds, "serial" );

DataTable ^m_pTable = ds->Tables["serial"];

DataRow ^pNewRow = m_pTable->NewRow();
pNewRow["SerialNum"] = szSerial;

m_pTable->Rows->Add( pNewRow );

pNewRow->AcceptChanges();

sa->Update( ds, "serial" );

array<DataRow ^> ^aRow = ds->Tables["serial"]->Select();

int i;
for( i=0; i<aRow->Length; ++i )
{
/* SHOWS THE VALUE I ADDED! */
MessageBox::Show( Convert::ToString( aRow[i]["SerialNum"] ) );
}


m_dbConnection->Close();


Thanks in advance,
T

Report this thread to moderator Post Follow-up to this message
Old Post
TBass
04-14-08 09:48 AM


Re: ADO :: Adding Row, but changes not stored
Here's what I ended up doing to make it work, should anyone have a
similar problem:

/*
* INSERT (OR DO ANYTHING) USING SQL COMMANDS
*/


String ^insertSQL = gcnew String("INSERT INTO serial (SerialNum)
VALUES( '" + szSerial + "' );");
OleDbCommand ^command = gcnew OleDbCommand(insertSQL);
command->Connection = m_dbConnection;

m_dbConnection->Open();
command->ExecuteNonQuery();


m_dbConnection->Close();

Report this thread to moderator Post Follow-up to this message
Old Post
TBass
04-16-08 12:50 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

VC++ archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:55 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.