Link to home
Start Free TrialLog in
Avatar of Raggdog
RaggdogFlag for Norway

asked on

System.IndexOutOfRangeException: price

Hi Experts

I hope some of you can assist me in this.
My webapplication (asp.net/c#) works like a charm on localhost. But when I put it out on the server I get a server error saying System.IndexOutOfRangeException: price
Highlighted piece of code: "string pris = rdrVarer["pris"].ToString().Replace(",0000", ".00");"

This happens when I click the button to move the items in the basket and place them in the orders table

Can anyone please point me in the right direction here because I don't know what to look for

This is the code behind for this particular button:
// move data from hk to orders
 
                    SqlCommand sqlHentvarer = new SqlCommand("select vare_id,cast(pris as numeric(10,2)),storrelse,antall from hk where session_id ='" + Session.SessionID + "'", sqlConn);
 
                    SqlDataReader rdrVarer = sqlHentvarer.ExecuteReader();
 
                    // make loop 
 
                    while (rdrVarer.Read())
                    {
                        // norwegian vs english configuration
 
                        string pris = rdrVarer["pris"].ToString().Replace(",0000", ".00");
                        
 
                        SqlCommand sqlSettinnOrdre = new SqlCommand("insert into ordrelinjer (ordre_id,vare_id,pris,storrelse,antall) values ("
                                                                + OrdreID + "," + rdrVarer["vare_id"] + "," + pris
                                                                + "," + rdrVarer["storrelse"] + rdrVarer["antall"] + ")", sqlConn);
 
                        sqlSettinnOrdre.ExecuteNonQuery();
 
 
                    }

Open in new window

Avatar of Solar_Flare
Solar_Flare

it looks as though the database the server uses does not have the "pris" column.

are you connecting to the exact same database on your development machine and server?
Avatar of Raggdog

ASKER

yes... it is the exact same
Avatar of Raggdog

ASKER

I use the same database both on the server and localhost.
Why is there this works on localmachine - all orders are placed - and not on the server...?

Please people...
Hi girl, can you put more details, your stack trace for instance?
ASKER CERTIFIED SOLUTION
Avatar of Anurag Agarwal
Anurag Agarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Raggdog

ASKER

@anuragal, thank you...  
It works like a charm..


Maya