I want to return a DataTable from DLL file that is Created from ClassLibrary Project. So is it possible to return a DataTable from the DLL file which contain the code to return the DataTable? And also i want to use this in asp.net website.
Plz give any suggestions…!
EG:
public DataTable getData()
{
DataTable dt=new DataTable("Test");
SqlCommand cmd=new SqlCommand();
SqlDataAdapter da=new SqlDataAdapter();
using(SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["EMP"].ConnectionString))
{
da.SelectCommand = con.CreateCommand();
da.SelectCommand.CommandType = CommandType.Text;
da.SelectCommand.CommandText = "Select *from EMP";
da.SelectCommand.Connection = con;
try
{
con.Open();
da.Fill(dt);
con.Close();
}
catch (Exception ec)
{
}
finally
{
con.Close();
}
}
return dt;
}
Yes it is possible to return Datatable. What you are doing is correct. Make sure that you provide Connection string value of
some how in dll.
You can provide parameter of getData