Answers for "save data from datatable to database c#"

C#
4

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);
Posted by: Guest on August-20-2020
0

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;
}
Posted by: Guest on September-20-2021

Code answers related to "save data from datatable to database c#"

C# Answers by Framework

Browse Popular Code Answers by Language