Skip to content

Values from database

Felipe Marks

Asked Jun 1, 2007, 2:38 AM EDT1 answer
Share
LinkedInX
Hi there

Im havin a problem to get values from a table into variables, setting each variable with row values. To get values per column is easy I use this code:

string sql = "select val from fmFactor";

conn.Open();

OdbcCommand cmd = new OdbcCommand(sql,conn);

OdbcDataReader dr = cmd.ExecuteReader();

while(dr.Read())

{

fmDiscount = dr.GetDouble(0);

fmAdvert = dr.GetDouble(1);

fmExcess = dr.GetDouble(2);

fmTotal = dr.GetDouble(3);

}

conn.Close();
----
but thats for diffirent colums not rows
if any12 could assist me in this. I don't think its difficult at all tho
but Im stuck. o and im not using the dataset and adapters stuff to use the datarow thing.

thanx

  

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    the sql should have atleat 4 double  fields selected so that you can use the rest of the code.
    string sql = "select val1, val2, val3, val4 from fmFactor";

    then your rest of code will work.  If you have in database val1, val2, val3 and val4 double fields

    --Hari
    0