1 Replies - 1435 Views - Last Post: 26 November 2013 - 10:27 PM Rate Topic: -----

#1 Vault-Boy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 18-May 13

Specified argument was out of the range of valid values.

Posted 26 November 2013 - 05:52 PM

Full error:
Specified argument was out of the range of valid values.
Parameter name: startIndex

Here's the code for the error:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using System.Data.SqlTypes;
using Wishlist.Properties;
using System.Windows.Forms;
using Db4objects;

namespace Wishlist
{
    class databaseupdate
    {
        public static Boolean e = false;
        public static int count;
        public string connection;

        public static void Update() { 
         
        }

        public static void Insert(string name, string desc, string price, string user, Uri website)
        {
            SqlConnection c = new SqlConnection(Properties.Settings.Default.itemsConnectionString);
            c.Database.Insert(count + 1, name);
        }

    }
}




The line I'm getting the error on is:

c.Database.Insert(count+ 1, name);


What am I doing wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: Specified argument was out of the range of valid values.

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,742
  • Joined: 05-May 12

Re: Specified argument was out of the range of valid values.

Posted 26 November 2013 - 10:27 PM

If the string Database is less than 2 characters, then you can not insert name starting at the second character.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1