Oracle Error: Unable to cast object of type Oracle.DataAccess.Types.OracleDate to type System.IConvertible

I'm getting the following error when I try to convert an OracleParameter Date field to a .net Datetime field.
{"Unable to cast object of type 'Oracle.DataAccess.Types.OracleDate' to type 'System.IConvertible'."} System.InvalidCastException.
I've included snipets of the code.  The stored procedure it calls is working OK. I can bind it to a gridview without a problem.  What I can't do it take the return value and convert it into a .net DateTime field. I tried to convert it to a string but that only returns the date portion of the field - I need the time as well. Ultimately, I want the field to be tied to a calendar control.  All help appreciated. Thanks.

OracleParameter oraParmGet_START_DATE_OUT = new OracleParameter();
...
oraParmGet_START_DATE_OUT.ParameterName = "START_DATE_OUT";
oraParmGet_START_DATE_OUT.OracleDbType =
OracleDbType.Date;
oraParmGet_START_DATE_OUT.Direction =
ParameterDirection.Output;
oraParmGet_START_DATE_OUT.Size = 38;
...
DateTime startDate = Convert.ToDateTime(oraParmGet_START_DATE_OUT.Value);

 


 

0
gphares
4/29/2008 3:35:59 PM
asp.net.oracle 2269 articles. 0 followers. Follow

2 Replies
3898 Views

Similar Articles

[PageSpeed] 26

This should work I think... 

DateTime startDate = (DateTime)(OracleDate)oraParmGet_START_DATE_OUT.Value;

 

Hope it helps,
Greg

0
greg
4/29/2008 5:51:18 PM

That worked. Thanks.

 

0
gphares
4/29/2008 6:29:08 PM
Reply:

Similar Artilces:

Error showing up: Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'.
Hi, I am trying to pass date values from two textboxes in a stored procedure from ASP.net page. However, it seems it is not passing the date properly. I am getting the following error at the following line: cmd_r.Parameters("@initial_est_date").Value = Convert.ToDateTime(Textbox1)  and the error is as stated in the title. I would appreciate any help to resolve this. Thanks  CODE:<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %><%@ Import Namespace="System.Data.Common" %> <%@ I...

Unable to cast object of type 'System.String[]' to type 'System.IConvertible'.
hi expert   i try get the string from request.querystring("CID") from the error messege i know that is string[] (array) how to convert it to int32 and request.querystring("CID") is int value   Line 19: protected void ObjectDataSourceCarPicture_Inserting(object sender, ObjectDataSourceMethodEventArgs e) Line 20: { Line 21: e.InputParameters.Add("CID", Convert.ToInt32(Request.QueryString.GetValues("CID")) ); Line 22: // e.InputParameters.Add("CID", Convert.ToInt32( Convert.ToString( a Request.QueryString.GetValues("CID"))))); Line 23: ...

Unable to cast object of type 'System.String' to type 'System.Byte[]' error
Hello, I have some binary data in a MySQL database, and im trying to convert it to a file. Before, when i was using the ms sql express 2005 database, everything was working fine. But then i migrated to MySQL because of budget issues. The following is the block of code that produces the error.private void showDbImage() {string ImageId = Request.QueryString["img"];   //build our query statementstring sqlText = "SELECT DownloadFile, DownloadType FROM DownloadTable WHERE DownloadName = '" + ImageId +"'";  OdbcConnection connection = new O...

ERROR: Unable to cast object of type 'System.Boolean' to type 'System.String'
I created a class to update, insert, select and delete data with an object data source but I am getting the following error... body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-wei...

error --------------------unable to cast object of type'system.data.datatable'to type system.data.datarow[]
getting error in the bold line  so plz help me to resolve the problem  Private Sub form1_load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load con.Open() Strquery = "Select * from optimizer" adp = New SqlDataAdapter(Strquery, con) adp.Fill(ds, "optimizer") dtb = ds.Tables("optimizer") 'cmdCommand = New SqlCommand(Strquery, con) Try 'dr = cmdCommand.ExecuteReader fs = File.Open("c:/abc.txt", FileMode.Create, FileAccess.Write, FileShare.None) sw = New StreamWriter(fs) For Each drow In ds.Tables sw.WriteLine(drow(0).ToString +...

Unable to cast object of type 'TYPE' to type 'TYPE'.
I've got a custom class and collection...I want to use them to databind a Grid, and persist the state using a Session variable.  However I keep getting the above error **Sometimes...There will be times when it works fine, and times when it totally craps out.System.InvalidCastException: Unable to cast object of type 'ApprovalCycleCollection' to type 'ApprovalCycleCollection'. This should work fine, no?  I want a property to use in all my foreach loops   public ApprovalCycleCollection NewApprovalCycle { get { if (Se...

SqlDataSource.Select Error: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.
I am trying to use the select statement to put a field from my database using a SqlDataSource named 'FileBase.' I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. Description:...

SqlDataSource.Select Error: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.
I am trying to put the data from a field in my database into a row in a table using the SQLDataSource.Select statement. I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code, I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. Descri...

How do I get around this error "Unable to cast object of type 'System.DBNull' to type 'System.String' "
I am using Visual Developer 2008 Express Edition for the first time, and I keep getting the following error below. The site allows anyone to enter with a valid username and password, but even when I logoff the site I get the same error....like the memory or database is not getting refreshed. I would think that when I initially compile the site that anything left in memory would be flushed out. Can someone please help me to figure this out. Thanks,Ramell P.S. The site is programmed using C#    Unable to cast object of type 'System.DBNull' to type 'System.String&...

Update error , "Unable to cast object of type 'System.DBNull' to type 'System.String'" , using DataSet as a datasource
Hi All, The following sample code is for testing dw.UpdateData using dataset as the data source. The data retrieval and display part under Form1_Load works fine. However, inputting some values in a new row and calling dw.UpdateData causes the following error: "Unable to cast object of type 'System.DBNull' to type 'System.String'" The error seems to occur when a datawindow column value has been changed from null value. Does anyone know how to fix the error ? Thank you for your advice. I use DW2.5 (build 8542), VS2005 pro, MS SQL Express. ...

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.
I am tring to retieve a single node from my BLL code which retrieve one instane of Repot object:DataView dv = (DataView)objBoutPrep.Select();I am getting error:Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'. The BLL code returns onle one object and not a list of objects.Please help Client code: <asp:ObjectDataSource ID="objBoutPrep" runat="server" SelectMethod="GetRByID" UpdateMethod="UpdateT" TypeName="MB.K.BLL.G.Report"> <SelectParameters> <asp:Query...

System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
Hello , I am a data table with null able Columns.I am not able to catch the value for DBNull. I did set a value to be returned as empty in dataset. Here is the code where i am trying to catch.1 public List GetStores() 2 { 3 List tmpStore = new List(); 4 StoresService.shopDBDataSet.StoresDataTable stores = 5 storesService.GetStores(); 6 for (int i = 0; i < stores.Count ; i++) 7 { 8 Store store = new Store(); 9 store.StoreID = stores[i].StoreID...

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Hi All, I am trying to retrieve a Picture from an SQL 2005 database. Here is my code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListingID As String = (Request.QueryString("GUID")) 'Connect to the database and bring back the image contents & MIME type for the specified pictureUsing myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionStringListings").ConnectionString) Const SQL As String = "SELECT [Pic1Ext], [Picture1] FROM [Listings] WHERE [ListingID] = @ListingID"C...

System.InvalidCastException: Unable to cast object of type 'System.Web.HttpInputStream' to type 'System.IO.FileStream'
I am trying to create a webpage that takes a file that someone want to upload and chop the file into smaller pieces, and then put back together again.  I have been trying to convert some code I found on Codeproject (FileSplitMerge).  They did it with VB which is what I want to use but it is a project not a web site so...  The problem that I am running into is I keep getting an error when I try to set: FileStream = HttpPostedFile.InputStream (I am using variables in my code) but I keep getting an error of: System.InvalidCastException: Unable to cast object of type 'Sys...

Web resources about - Oracle Error: Unable to cast object of type Oracle.DataAccess.Types.OracleDate to type System.IConvertible - asp.net.oracle

bradbamford (@bradbamford) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Some More Notes on VB
I have some familiarity with the history of VB. I do know that, at one time, VB.NET was originally planned to be more faithful to traditional ...

闈掑矝杞帶
... info, Boolean parseDecimal) 鍦?System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) 鍦?System.String.System.IConvert ...

Administrator - CODE SNIPPETS
public static bool IsSmallerThan (this TOne baseValue, TTwo checkValue) where TOne : struct,IComparable, IComparable , IConvertible, IEquatable ...

JMPInline: Performance
JMPInline Read up on .NET news, tips, cautions... and other areas of technological interest. Showing posts with label Performance . Show all ...

Resources last updated: 1/21/2016 11:37:06 PM