C# create DataTable
DataTable dt = new DataTable();
dt.Clear();
dt.Columns.Add("Name");
dt.Columns.Add("Marks");
DataRow _ravi = dt.NewRow();
_ravi["Name"] = "ravi";
_ravi["Marks"] = "500";
dt.Rows.Add(_ravi);
C# create DataTable
DataTable dt = new DataTable();
dt.Clear();
dt.Columns.Add("Name");
dt.Columns.Add("Marks");
DataRow _ravi = dt.NewRow();
_ravi["Name"] = "ravi";
_ravi["Marks"] = "500";
dt.Rows.Add(_ravi);
how to retrieve data from database in c# using datatable
using System.Data;
using System.Data.SqlClient;
public DataTable StudentView()
{
SqlConnection sqlCon = new SqlConnection(@"Server= localhostSQLINSTANCENAME; Database= DBNAME; Integrated Security=True;");
SqlDataAdapter sqlDa = new SqlDataAdapter("QUERY", sqlCon);
DataTable dtbl = new DataTable();
sqlDa.Fill(dtbl);
return dtbl;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us