asp.net - c# QueryString exception -


in following code, got following error.

an exception of type 'system.argumentoutofrangeexception' occurred in mscorlib.dll not handled in user code

additional information: index out of range. must non-negative , less size of collection.

the code :

protected void page_load(object sender, eventargs e) {     prid.text = request.querystring[0];     using (sqlconnection connection = connectionmanager.getconnection())     {         string cmd = "select imagecolor, quantity, productname, price, screensize, screentype, processor, internal_memory, ram, sd_card, camera, bettery mobtabspecifications mobtabspecifications.prid ='" + prid.text+"'";         sqlcommand command = new sqlcommand(cmd, connection);         sqldatareader reader = command.executereader();         while (reader.read())         {              img.imageurl = "../image/"+ reader[0] string;             quantity.text = reader[1] string;             prname.text = reader[2] string;             prprice.text = reader[3] string;             ssize.text = reader[4] string;             stype.text = reader[5] string;             prpower.text = reader[6] string;             intmemory.text = reader[7] string;             ram.text = reader[8] string;             sdcard.text = reader[9] string;             camera.text = reader[10] string;             bettery.text = reader[11] string;             break;         }      } } 

if want active product after & need set products in basket id if 1 have idea please tell me in comment

try use name of each column:

quantity.text = reader["quantity"] string; 

instead of

quantity.text = reader[1] string; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -