public OracleLob dbrGetTempBlob()
{
OracleCommand lComm = null;
OracleLob     lBlob = null;
OracleTransaction lTran = null;

try 
{
/*
if(gConn.State.ToString().Equals("Closed")) 
{
gConn.Open();                   
}
*/
lTran = gConn.BeginTransaction();
lComm = gConn.CreateCommand(); lComm.Transaction = lTran; lComm.CommandText = "declare wiz blob; begin dbms_lob.createtemporary(wiz, false,0); :tempblob := wiz; end;";
lComm.Parameters.Add(new OracleParameter("tempblob", OracleType.Blob)).Direction = ParameterDirection.Output;
lComm.ExecuteNonQuery();
lBlob = (OracleLob)lComm.Parameters["tempblob"].Value;
//gConn.Close();
lTran.Commit();
}
catch(OracleException ex) 
{
System.Console.WriteLine(ex.Message.ToString());
//gConn.Close();
}
return lBlob;
} public void dbrNewRow(string rTableName) 
{
DataRow lNewRow    = null;
string  lTableName = "";
try 
{
lTableName = procTableName(rTableName);
lNewRow    = gDataS.Tables[lTableName].NewRow();
gDataRow   = (DataRow) lNewRow;
}
catch(Exception ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
} public void dbrFindRow(string rTableName) 
{
DataRow lDataRow   = null;
string  lTableName = "";
try 
{
lTableName = procTableName(rTableName);
lDataRow   = gDataS.Tables[rTableName].Rows[0];
gDataRow   = lDataRow; }
catch(Exception ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
}
               /*
Note: If there are more than one record in db by select sql, 
you must get the records count by dbrGetRowCount() and loop it;
Example 
    for(int i=0;i<dbrGetRowCount();i++) {
   dbrMoveNextRow(i);//Must place it first;
   .........
    }
*/
public void dbrMoveNextRow(int rRowIndex) 
{
gDataRow = gRowCol[rRowIndex];
dbrSuccess();
} public void dbrInsert(string rTableName) 
{
DataSet              lDataSet  = gDataS;
OracleDataAdapter    lDAdapter = gDataA;
OracleCommandBuilder lCBuilder = null;
            string               lTableName= "";
try 
{
lCBuilder = new OracleCommandBuilder(lDAdapter);
lDAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
lTableName = procTableName(rTableName);
gDataS.Tables[lTableName].Rows.Add(gDataRow);
gDataA.Update(gDataS, lTableName);
dbrSuccess();
}
catch(OracleException ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
} public void dbrUpdate(string rTableName) 
{
OracleCommandBuilder lCBuilder = null;
string               lTableName= "";
try 
{
lTableName= procTableName(rTableName);
lCBuilder = new OracleCommandBuilder(gDataA);
gDataA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
gDataA.Update(gDataS, lTableName);
dbrSuccess();
}
catch(OracleException ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
} public void dbrDelete(string rTableName) 
{
OracleCommandBuilder lCBuilder = null;
string               lTableName= "";
try 
{
lTableName= procTableName(rTableName);
lCBuilder = new OracleCommandBuilder(gDataA);
gDataA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
gDataRow.Delete();
gDataA.Update(gDataS, lTableName);
dbrSuccess();
}
catch(Exception ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
}                //Get the sequence of oracle db;
public decimal dbrGetSequence(string rSqlStr) 
{
OracleCommand    lCommand  = null;
OracleDataReader lDReader  = null;
decimal          lSequence = 0m;
try 
{
/*
if(gConn.State.ToString().Equals("Closed"))
    gConn.Open();
*/
lCommand = gConn.CreateCommand();
lCommand.CommandText = rSqlStr;
lCommand.CommandType = CommandType.Text;
lDReader = lCommand.ExecuteReader();
lDReader.Read();
lSequence = (decimal) lDReader.GetDecimal(0);
lDReader.Close();
//gConn.Close();
}
catch(OracleException ex) 
{
if(lDReader != null)
lDReader.Close();
System.Console.WriteLine(ex.Message.ToString());
}
return lSequence;
}               //Get the records count;
public int dbrGetRowCount() 
{
return gRowCol.Count;
}                //Update the char(or varchar) field in db;
public void dbrUpdateString(string rColumnName, string rContent) 
{
try 
{
gDataRow[rColumnName] = rContent;
dbrSuccess();
}
catch(OracleException ex) 
{
System.Console.WriteLine(ex.Message.ToString());
}
}

解决方案 »

  1.   

    public void dbrUpdateString(int rColumnNumber, string rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateBytes(string rColumnName, byte[] rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    }
    public void dbrUpdateBytes(int rColumnNumber, byte[] rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateLong(string rColumnName, long rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateLong(int rColumnNumber, long rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateInt(string rColumnName, int rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateInt(int rColumnNumber, int rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } //Please Note: the Number type of Oracle correspond the Decimal type of .NET; 
    public void dbrUpdateDecimal(string rColumnName, decimal rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateDecimal(int rColumnNumber, decimal rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    }
            
    public void dbrUpdateDate(string rColumnName, DateTime rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateDate(int rColumnNumber, DateTime rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    }

    public void dbrUpdateDouble(string rColumnName, double rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateDouble(int rColumnNumber, double rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    }
                    //Note: the dbrUpdateBlob method is insteaded by the dbrUpdateBytes method use to
    //update the data of blob type, but you still can use it to update;
    public void dbrUpdateBlob(string rColumnName, OracleLob rContent) 
    {
    try 
    {
    gDataRow[rColumnName] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    } public void dbrUpdateBlob(int rColumnNumber, OracleLob rContent) 
    {
    try 
    {
    gDataRow[rColumnNumber] = rContent;
    dbrSuccess();
    }
    catch(OracleException ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    }
    }
      

  2.   

    public string dbrGetString(string rColumnName) 
    {
    string lRtnStr = "";
    try 
    {
    lRtnStr = (string)gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return null;
    }
    } public string dbrGetString(int rColumnNumber) 
    {
    string lRtnStr = "";
    try 
    {
    lRtnStr = (string)gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return null;
    }
    } public int dbrGetInt(string rColumnName) 
    {
    int lRtnStr = 0;
    try 
    {
    lRtnStr = (int)gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine("dbrGetInt() Exception = {0}", ex.Message.ToString());
    return lRtnStr;
    }
    } public int dbrGetInt(int rColumnNumber) 
    {
    int lRtnStr = 0;
    try 
    {
    lRtnStr = (int)gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine("dbrGetInt() Exception = {0}", ex.Message.ToString());
    return lRtnStr;
    }
    } public long dbrGetLong(string rColumnName) 
    {
    long lRtnStr = 0;
    try 
    {
    lRtnStr = (long)gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    } public long dbrGetLong(int rColumnNumber) 
    {
    long lRtnStr = 0;
    try 
    {
    lRtnStr = (long)gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    } //The Number type of Oracle correspond the Decimal type in .NET; 
    public decimal dbrGetDecimal(string rColumnName) 
    {
    decimal lRtnStr = 0.0m;
    try 
    {
    lRtnStr = (decimal)gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    } public decimal dbrGetDecimal(int rColumnNumber) 
    {
    decimal lRtnStr = 0.0m;
    try 
    {
    lRtnStr = (decimal)gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    } public DateTime dbrGetDateTime(string rColumnName) 
    {
    DateTime lRtnStr = new DateTime();
    try 
    {
    lRtnStr = (DateTime)gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ee) 
    {
    System.Console.WriteLine("Exception = {0}", ee.Message.ToString());
    return lRtnStr;
    }
    } public DateTime dbrGetDateTime(int rColumnNumber) 
    {
    DateTime lRtnStr = new DateTime();
    try 
    {
    lRtnStr = (DateTime)gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    }
    /* The dbrGetBytes method is use to get the data of BLOB type from db,
           the byte[] convert to BLOB is done between the DataSet class and database;
     */
    public byte[] dbrGetBytes(string rColumnName) 
    {
    byte[] lRtnStr = null;
    try 
    {
    lRtnStr = (byte[])gDataRow[rColumnName];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    } public byte[] dbrGetBytes(int rColumnNumber) 
    {
    byte[] lRtnStr = null;
    try 
    {
    lRtnStr = (byte[])gDataRow[rColumnNumber];
    dbrSuccess();
    return lRtnStr;
    }
    catch(Exception ex) 
    {
    System.Console.WriteLine(ex.Message.ToString());
    return lRtnStr;
    }
    }
    }
    }