PC Review


Reply
Thread Tools Rate Thread

Can't get record to insert into Access

 
 
Drew Burlingame via .NET 247
Guest
Posts: n/a
 
      23rd Jan 2005
I have a windows service that will insert records into an Accessdatabase. Or at least that's the idea. The insert isn'thappening, but the code runs without raising any errors. When Irun the generated sql statement from a query window in Access,the record inserts just fine. Can anyone help me?

string sqlInsert = "INSERT INTO checks( PageNo, Template,OriginFile, TargetFile, MICR, Account, Routing, CheckNumber,CheckDate, CheckAmount, ScanBatchNum ) VALUES( '{0}', '{1}','{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}')";
StringBuilder sb = new StringBuilder();
using( OleDbConnection cn = new OleDbConnection( m_ConnString ))
{
cn.Open();
using( OleDbCommand cmd = new OleDbCommand( "", cn ) )
{
foreach( ChecksDS.ChecksRow row in checkRecords )
{
sb.AppendFormat( sqlInsert, row.PageNo, row.Template,row.OriginFile, row.TargetFile, row.MICR, row.Account,row.Routing, row.CheckNum, row.CheckDate, row.CheckAmount,row.ScanBatchNum );
cmd.CommandText = sb.ToString();
cmd.ExecuteNonQuery();
sb.Remove( 0, sb.Length );
}
}
cn.Close();
}

Here's a generated sql statement.

INSERT INTO checks( PageNo, Template, OriginFile, TargetFile,MICR, Account, Routing, CheckNumber, CheckDate, CheckAmount,ScanBatchNum ) VALUES( '3', 'Check', 'C:\ProgramFiles\FormStorm\urm\Queues\0120040901160314.tif', 'C:\ProgramFiles\FormStorm\URM\ImageExp\090920049091443253.tif','A021204005A 0001538C 0404', '021204005', '0001538', '0404','', '20.00', '09092004909144325' );

I've tried with and without the ending semi-colon. What am Imissing?

Thanks
--------------------------------
From: Drew Burlingame

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>W3E/7KDtXkaxBUqfx/Y9Jg==</Id>
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJpYW4gQnJvd24=?=
Guest
Posts: n/a
 
      24th Jan 2005
Hi Drew,

My first thought is do you have "Allow Zero Length" set to yes for the
CheckDate field in your access table? If you do not it may have a problem
there. Otherwise I do not see any glaring issues. If that is not it can you
try to create a sample app that has the same behavoir and post it? That will
help us in diagnosing the problem.

Hope this helps.
----------------------------
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access insert a new record =?Utf-8?B?Ry4gR2Vyc2hlbGxpbmc=?= Microsoft Access 7 19th Oct 2006 05:41 PM
Can't get record to insert into Access Drew Burlingame via .NET 247 Microsoft ADO .NET 2 28th Dec 2004 02:30 PM
Can't get record to insert into Access Drew Burlingame via .NET 247 Microsoft ADO .NET 1 18th Nov 2004 02:40 AM
Can't get record to insert into Access Drew Burlingame via .NET 247 Microsoft ADO .NET 1 31st Oct 2004 01:15 PM
Can't get record to insert into Access Drew Burlingame via .NET 247 Microsoft ADO .NET 1 17th Oct 2004 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:09 PM.