I'm converting an application from ASP/vbscript to ASP.NET and C#. With ASP I would read in a table, go to the bottom, extract the values of the columns, move to the previous column, extract those values, make some calculations, then create the html page.
Here's my old code using vbscript:
note: "orsView" is defined as a recordset object.
note: "connect" is my connection to an Access database.
sql="SELECT * from " & session("mpgtable") & ";"
workyear = session("workyear")
orsView.open sql, connect, 3
orsView.MoveLast
odonew = orsView("odometer")
galnew = orsView("gallons")
filldate = orsView("filldate")
cost = orsView("cost")
orsView.MovePrevious
odoold = orsView("odometer")
ododiff = odonew - odoold
mpgnew = ododiff / galnew
Now I'm trying to use Oracle and ASP.NET. Here's what I've got so far, but I cannot figure out a way to get at the actual data elements like I did above with, eg., odonew = orsView("odometer").
Here's what I've got so far:
int odonew, odoold, ododiff;
DateTime filldate;
float mpgnew, galnew, cost;
string sql = "select filldate, odometer, gallons, cost from " + mpgtable;
OracleConnection mpgconn = new OracleConnection();
mpgconn.ConnectionString = "Data Source=orcl; Persist Security Info=True; User ID=mpg;Password=mpg;";
OracleCommand command = new OracleCommand();
command.Connection = mpgconn;
command.CommandType = CommandType.Text;
command.CommandText = sql;
OracleDataAdapter adapter = new OracleDataAdapter();
adapter.SelectCommand = command;
DataSet ors = new DataSet();
mpgconn.Open();
adapter.Fill(ors, "'" + mpgtable + "'");
mpgconn.Close();
The following "mess" is what I've been working on so far, trying to just be able to at least SEE a value in a database column somewhere. I've tried dozens of combinations, so what you see below is just where I am at this moment as I contemplate suicide. Can anyone tell me how to get to these values directly? Thanks in advance!
foreach (DataRow therow in ors.Tables[0].Rows)
{
foreach (DataColumn dc in ors.Tables[0].Columns)
{
filldate = Convert.ToSingle(ds.Tables[0].Rows[iLoop][dataColumnName]);
}
}
Here's my old code using vbscript:
note: "orsView" is defined as a recordset object.
note: "connect" is my connection to an Access database.
sql="SELECT * from " & session("mpgtable") & ";"
workyear = session("workyear")
orsView.open sql, connect, 3
orsView.MoveLast
odonew = orsView("odometer")
galnew = orsView("gallons")
filldate = orsView("filldate")
cost = orsView("cost")
orsView.MovePrevious
odoold = orsView("odometer")
ododiff = odonew - odoold
mpgnew = ododiff / galnew
Now I'm trying to use Oracle and ASP.NET. Here's what I've got so far, but I cannot figure out a way to get at the actual data elements like I did above with, eg., odonew = orsView("odometer").
Here's what I've got so far:
int odonew, odoold, ododiff;
DateTime filldate;
float mpgnew, galnew, cost;
string sql = "select filldate, odometer, gallons, cost from " + mpgtable;
OracleConnection mpgconn = new OracleConnection();
mpgconn.ConnectionString = "Data Source=orcl; Persist Security Info=True; User ID=mpg;Password=mpg;";
OracleCommand command = new OracleCommand();
command.Connection = mpgconn;
command.CommandType = CommandType.Text;
command.CommandText = sql;
OracleDataAdapter adapter = new OracleDataAdapter();
adapter.SelectCommand = command;
DataSet ors = new DataSet();
mpgconn.Open();
adapter.Fill(ors, "'" + mpgtable + "'");
mpgconn.Close();
The following "mess" is what I've been working on so far, trying to just be able to at least SEE a value in a database column somewhere. I've tried dozens of combinations, so what you see below is just where I am at this moment as I contemplate suicide. Can anyone tell me how to get to these values directly? Thanks in advance!
foreach (DataRow therow in ors.Tables[0].Rows)
{
foreach (DataColumn dc in ors.Tables[0].Columns)
{
filldate = Convert.ToSingle(ds.Tables[0].Rows[iLoop][dataColumnName]);
}
}