Sebastian_OH
asked on
Problem inserting Data to Database in ASP.Net c#
Hi,
i try to insert every item from a class into a database.
When i run the program, the Data shows up in SQL, but the application throws the following exception:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
What can i do to fix it?
i try to insert every item from a class into a database.
When i run the program, the Data shows up in SQL, but the application throws the following exception:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
What can i do to fix it?
protected void btnCheckout_Click(object sender, EventArgs e)
{
ADDTest.Datasets.dsCribstoreTableAdapters.CheckoutTableAdapter dsCheckout = new ADDTest.Datasets.dsCribstoreTableAdapters.CheckoutTableAdapter();
int intItems = ShoppingCart.Instance.Items.Count;
for (int i = 0; i <= intItems; i++)
{
dsCheckout.Insert((string)ShoppingCart.Instance.Items[i].USer,(string)ShoppingCart.Instance.Items[i].ProductId,(int)ShoppingCart.Instance.Items[i].Quantity,(string)ShoppingCart.Instance.Items[i].ChrgDepartment,null,DateTime.Now);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.