I cannot seem to get datagrids with the oracle client working even thou I do not seem to have problems using the datareader exclusivly. Mostly I am just trying to test this out as I am not really a .NET person yet. It seems like it is having problems filling the dataset and with the datasource. Anyways in the midst of trying this, I tried bytefx with mysql. I didn't have any problems with like code translated.
Can anybody tell me what I am doing wrong? Or is this a bug? Example code below; -Mike ADAPTER -------------------------------------------------- <%@ Page Language="c#" %> <%@ Import Namespace="System.Data" %> <%@ Assembly name="System.Data.OracleClient" %> <%@ Import Namespace="System.Data.OracleClient" %> <script runat="server"> private void Page_Load(object sender, System.EventArgs e) { String strConn = "Data Source=oracle;User Id=me;Password=pass;"; String strSql = "SELECT * FROM me.names"; OracleConnection objConn = new OracleConnection(strConn); OracleDataAdapter dataAdapter = new OracleDataAdapter(); dataAdapter.SelectCommand = new OracleCommand(strSql, objConn); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); dtgOracle.DataSource = dataSet; dtgOracle.DataBind(); } </script> <html> <head> <title>Mono DataGrid Example</title> </head> <body> <asp:DataGrid runat="server" id="dtgOracle" BackColor="#eeeeee" Width="100%" HorizontalAlign="Center" Font-Size="10pt"> <HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="True" HorizontalAlign="Center" /> <AlternatingItemStyle BackColor="White" /> </asp:DataGrid> </body> </html> -------------------------------------------------- Returns this; ADAPTER-------------------------------------------------- Description: Error processing request. Error Message: HTTP 500. Stack Trace: System.NullReferenceException: Object reference not set to an instance of an object in <0x0000a> System.Data.OracleClient.Oci.OciHandle:op_Implicit (System.Data.OracleClient.Oci.OciHandle) in <0x0006a> System.Data.OracleClient.Oci.OciHandle:GetAttributeSByte (System.Data.OracleClient.Oci.OciAttributeType,System.Data.OracleClient.Oci.OciErrorHandle) in <0x00031> System.Data.OracleClient.Oci.OciParameterDescriptor:GetScale () in <0x001ee> System.Data.OracleClient.OracleDataReader:GetSchemaTable () in <0x000e8> System.Data.Common.DbDataAdapter:BuildSchema (System.Data.IDataReader,System.Data.DataTable,System.Data.SchemaType) in <0x0007e> (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:BuildSchema (System.Data.IDataReader,System.Data.DataTable,System.Data.SchemaType) in <0x00086> System.Data.Common.DbDataAdapter:FillTable (System.Data.DataTable,System.Data.IDataReader,int,int,int&) in <0x000b8> (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:FillTable (System.Data.DataTable,System.Data.IDataReader,int,int,int&) in <0x00184> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet,string,System.Data.IDataReader,int,int) in <0x000dc> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet,int,int,string,System.Data.IDbCommand,System.Data.CommandBehavior) in <0x00047> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet) in <0x000e8> ASP.datagrid_reader_aspx:Page_Load (object,System.EventArgs) in <0x0006a> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs) in <0x00075> System.Web.UI.Control:OnLoad (System.EventArgs) in <0x00024> System.Web.UI.Control:LoadRecursive () in <0x0018c> System.Web.UI.Page:InternalProcessRequest () in <0x000c2> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext) in <0x002e8> ExecuteHandlerState:Execute () in <0x00084> StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&) ------------------------------------------------------ Also, if I try to use the datareader to fill a datagrid READER------------------------------------------------------ <%@ Page Language="c#" %> <%@ Import Namespace="System.Data" %> <%@ Assembly name="System.Data.OracleClient" %> <%@ Import Namespace="System.Data.OracleClient" %> <script runat="server"> private void Page_Load(object sender, System.EventArgs e) { String strConn = "Data Source=oracle;User Id=me;Password=pass;"; String strSql = "SELECT * FROM names"; OracleConnection objConn = new OracleConnection(strConn); OracleCommand objCommand = new OracleCommand(strSql, objConn); objConn.Open(); dtgOracle.DataSource = objCommand.ExecuteReader(); dtgOracle.DataBind(); objConn.Close(); } </script> <html> <head> <title>Mono DataGrid Example</title> </head> <body> <asp:DataGrid runat="server" id="dtgOracle" BackColor="#eeeeee" Width="100%" HorizontalAlign="Center" Font-Size="10pt"> <HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="True" HorizontalAlign="Center" /> <AlternatingItemStyle BackColor="White" /> </asp:DataGrid> </body> </html> --------------------------------------------------- I recieve a READER--------------------------------------------------- System.NullReferenceException: Object reference not set to an instance of an object in <0x0000a> System.Data.OracleClient.Oci.OciHandle:op_Implicit (System.Data.OracleClient.Oci.OciHandle) in <0x0006a> System.Data.OracleClient.Oci.OciHandle:GetAttributeSByte (System.Data.OracleClient.Oci.OciAttributeType,System.Data.OracleClient.Oci.OciErrorHandle) in <0x00031> System.Data.OracleClient.Oci.OciParameterDescriptor:GetScale () in <0x001ee> System.Data.OracleClient.OracleDataReader:GetSchemaTable () in <0x00081> System.Data.Common.DbEnumerator:.ctor (System.Data.IDataReader,bool) in <0x00012> System.Data.Common.DbEnumerator:.ctor (System.Data.IDataReader) in <0x00020> System.Data.OracleClient.OracleDataReader:System.Collections.IEnumerable.GetEnumerator () in <0x00572> System.Web.UI.WebControls.PagedDataSource:GetEnumerator () in <0x0016c> System.Web.UI.WebControls.DataGrid:AutoCreateColumns (System.Web.UI.WebControls.PagedDataSource) in <0x00133> System.Web.UI.WebControls.DataGrid:CreateColumnSet (System.Web.UI.WebControls.PagedDataSource,bool) in <0x00541> System.Web.UI.WebControls.DataGrid:CreateControlHierarchy (bool) in <0x0004a> System.Web.UI.WebControls.BaseDataList:OnDataBinding (System.EventArgs) in <0x00010> System.Web.UI.WebControls.BaseDataList:DataBind () in <0x000c1> ASP.datagrid_reader_aspx:Page_Load (object,System.EventArgs) in <0x0006a> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs) in <0x00075> System.Web.UI.Control:OnLoad (System.EventArgs) in <0x00024> System.Web.UI.Control:LoadRecursive () in <0x0018c> System.Web.UI.Page:InternalProcessRequest () in <0x000c2> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext) in <0x002e8> ExecuteHandlerState:Execute () in <0x00084> StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&) --------------------------------------------------------------- However, something like the example runs fine. --------------------------------------------------------------- <%@ Page Language="c#" %> <%@ Import Namespace="System.Data" %> <%@ Assembly name="System.Data.OracleClient" %> <%@ Import Namespace="System.Data.OracleClient" %> <% String strConn = "Data Source=oracle;User ID=me;Password=pass;"; OracleConnection dbcon = new OracleConnection(strConn); dbcon.Open (); OracleCommand dbcmd = dbcon.CreateCommand(); string sql = "Select * From CIS440_Demo.names"; dbcmd.CommandText = sql; OracleDataReader reader = dbcmd.ExecuteReader(); %> <html> <head> <title>Example Oracle Connection</title> </head> <body> <table border="1" width="100%" id="table1"> <tr> <td><b>Faculty Number</b></td> <td><b>Last Name</b></td> <td><b>First Name</b></td> </tr><% while (reader.Read ()) { %> <tr> <td><%=reader["id"]%> </td> <td><%=reader["lastname"]%> </td> <td><%=reader["firstname"]%> </td> </tr> <% } %> </table> </body> </html> <% reader.Close (); reader = null; dbcmd.Dispose (); dbcmd = null; dbcon.Close (); dbcon = null; %> -------------------------------------------------------- _______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list