Question : Problem with C# OracleDataReader retrieving OracleLob in a record

I am having an issue that has been very frustrating.  I am using C# to select a record out of an Oracle Database.  the select statement returns one record based on record id, and the OracleClob field is in the first position of the results.  When the statement executes the first time, I retrieve the correct OracleLob value.  Subsequent executions of the select statement return the next record for all the fields other than the OracleLob.  That field never changes.  Every time that the Console.WriteLine(clob.Value); executes, it prints the first records clob every time.  Could someone point out what I am doing wrong?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:


        static private void GetProposalFile(Record rec)
        {
            string connectionString = GetConnectionString();
            using (OracleConnection connection = new OracleConnection())
            {
                connection.ConnectionString = connectionString;
                
                Console.WriteLine("State: {0}", connection.State);
                Console.WriteLine("ConnectionString: {0}",
                                  connection.ConnectionString);
                connection.Open();
                OracleCommand command = new OracleCommand();

                string sql = "select f.txt_file, t.*  from transactions t, trans_files f" +
                        " where t.record_id = :pOID" +
                        " and sequence_no = (select Max(tt.sequence_no) from transactions tt " +
                        " where tt.record_id = :pOID2 and tt.TRANS_STAT_CD = 'PRICED' and tt.TRANS_TYPE_CD = 'P')";

                command.CommandText = sql;
                command.Parameters.Clear();
                command.Parameters.Add(new OracleParameter(":pOID", OracleType.VarChar));
                command.Parameters[":pOID"].Value = rec.RecordID;
                command.Parameters.Add(new OracleParameter(":pOID2", OracleType.VarChar));
                command.Parameters[":pOID2"].Value = rec.RecordID;
                
                Console.WriteLine("SQLCommand: " + command.CommandText);

                command.Connection = connection;
                OracleDataReader reader = command.ExecuteReader();
                
                
                reader.Read();
                if (reader != null)
                {
                    OracleLob clob = reader.GetOracleLob(0);
                    long filesize = clob.Length;

                StreamWriter file = new StreamWriter("C:\\Documents and Settings\\user\\Desktop\\Temp\\RecordExtract\\" 
                        + rec.RecordID + "-" + rec.PropOrdInd + rec.PropTypCd + "-" + rec.LineItemCnt + ".txt",false);
                    file.WriteLine(clob.Value);
                    file.Close();
                    Console.WriteLine(clob.Value);
                    clob.Flush();
                    clob.Position = 0;
                }
                command.Dispose();
                
                reader.Close();
                reader.Dispose();
                connection.Close();
            }
        }

Answer : Problem with C# OracleDataReader retrieving OracleLob in a record

Hi,

Since the page directive is not included in the code you have posted i cant see whether you have tried this but there is a property called "MaintainScrollPositionOnPostback" that you can set to true in the page directive which will force the page to maitain the scroll position on postback.

/Carl.
Random Solutions  
 
programming4us programming4us