Results 1 to 2 of 2

Thread: INSERT not working *RESOLVED*

Threaded View

  1. #1

    Thread Starter
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    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
    Last edited by dj4uk; Jun 22nd, 2004 at 03:55 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width