using System.Data;
using System.Data.SqlClient;
public class test
{
SqlConnection con;
SqlDataAdapter adap;
DataSet ds;
//DataTable dt;
// DataRow[] dr;
public test()
{
//con=new SqlConnetion();
con.ConnectionString="initial catalog=rama;data source=TRIPATHI-PC\\SQLEXPRESS;integrated security=yes";
}
public void show_all()
{
adap=new SqlDataAdapter("t-fragment-content">
null refrence exception
using System;
using System.Data;
using System.Data;select*from student",con);
adap.Fill(ds);
int t=ds.Tables[0].Rows.Count;
for(int i=0;i<t;i++)
{
Console.WriteLine(ds.Tables[0].Rows[i][0]);
}
}
public static void Main()
{
test f=new test();
if(f!=null)
{
f.show_all();
}
}
}
why it give the nullreferenceexception
using System.Data;
using System.Data;select*from student",con);
adap.Fill(ds);
int t=ds.Tables[0].Rows.Count;
for(int i=0;i<t;i++)
{
Console.WriteLine(ds.Tables[0].Rows[i][0]);
}
}
public static void Main()
{
test f=new test();
if(f!=null)
{
f.show_all();
}
}
}
why it give the nullreferenceexception