0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by crishlay
0

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);

Edited by crishlay: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.