Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys, I have this code:

C#
public void chyt_data()
        {
        
            SqlCommand novyprikaz = new SqlCommand("SELECT * FROM table WHERE akce="+nc_zajezd_vyber, spojeni); 
            spojeni.Open();
            SqlDataReader precti = novyprikaz.ExecuteReader();

            if (precti.Read())
            {
...
                zcena1.Text = precti.GetDecimal(4).ToString();
                zcena2.Text = precti.GetDecimal(5).ToString();
                zcena3.Text = precti.GetDecimal(6).ToString();
            
            }
            spojeni.Close();
        }



It seelcts data and reads them from my SQL DB table, problém is that It doesnt read zcena1,zcena2 and zcena3, its because the data type in SQL table is numeric, on microsoft's website was written that i should read it with GetDecimal, but it doesn't work either.
Is there any solution?

Thanks in advance!
Posted
Updated 15-Oct-13 4:21am
v2

1 solution

zcena1.Text=precti[columnName/index].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900