hi i want to show my table in afrid view reading from database but i couldint i tried many times can any one help me this is my code:

<%@ Page Language="JScript" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data.sqlClient" %>



<html>
<head>
<title>Home page</title>
</head>
   <body>

      <form id="Form1" runat = "server">

       
      <script language = "JScript" runat="server" >

         function Page_Load( sender : Object, events : EventArgs ) 
         {
           var dbconn: OleDbConnection = new OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"));
           var qryString: String="SELECT StudentNan FROM Students"+"Faculty FROM Apointments";
            dbconn.Open();
            var dbCommand : OleDbCommand = new OleDbCommand(qryString,dbconn);
            var dataAdapter: OleDbDataAdapter= new OleDbDataAdapter(dbCommand);
            var dataTable:DataTable= new DataTable();
             var dataset: DataSet= new DataSet("Students");
             dataAdapter.Fill(dataTable,dataset);
            var dataView:DataView= new DataView(dataTable);
            
           dataGrid.DataSource= dataView;
           dataGrid.DataBind();
           
            dbconn.Close();
       
          }
      </script>

       
         <p>
            <asp:DataGrid id = "dataGrid" runat = "server"> 
            </asp:DataGrid>
         </p>


         <p>
             &nbsp;</p>


      </form>
   </body>
</html>

this is the erorr:

Source Error:


Line 27: var dataTable:DataTable= new DataTable();
Line 28: var dataset: DataSet= new DataSet("Students");
Line 29: dataAdapter.Fill(dataTable,dataset);
Line 30: var dataView:DataView= new DataView(dataTable);
Line 31:


thanks in advance

in your Fill method you can only fill datatable or dataset data
like
SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();
da.Fill(ds);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.