INSERT not working *RESOLVED*
I have the following code that should insert a row into an Access database. I know that this code is being executed as I've debugged my application. No error is displayed when it is executed. However, ExecuteNonQuery returns 0 which means zero rows were updated in the database. If anyone could point out where I'm going wrong I would appreciate it.
Code:
cmdResult = new OleDbCommand( "INSERT INTO tbl_results ( url, keyword, rank, query_date, account_id ) VALUES ( @URL, @Keyword, @Rank, @Date, @AccountID )", dbConn );
cmdAccounts.Parameters.Add( "@URL", r.resultElements[0].URL );
cmdAccounts.Parameters.Add( "@Keyword", keyword );
cmdAccounts.Parameters.Add( "@Rank", OleDbType.Integer );
cmdAccounts.Parameters["@Rank"].Value = i + 1;
cmdAccounts.Parameters.Add( "@Date", OleDbType.Date );
cmdAccounts.Parameters["@Date"].Value = queryDate;
cmdAccounts.Parameters.Add( "@AccountID", OleDbType.Integer );
cmdAccounts.Parameters["@AccountID"].Value = cmbDldAccounts.SelectedValue;
cmdAccounts.ExecuteNonQuery();
Example parameter values for this are as follows:
r.resultElements[0].URL is of type string e.g. 'http://www.vbforums.com'
keyword is of type string e.g. 'visual basic'
i is type int e.g. 1
queryDate is of type DateTime and has a value of DateTime.Now
cmbDldAccounts.SelectedValue is of type int e.g. 5.
Cheers
DJ