i am trying to store the csv file into the sql server database using asp dot net.
but i got this error . so kindly correct error and show to me.
i got a assembly reference error. so which reference i have to use this program,and how to add the reference
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnimport_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString=("Data source=ARUNAMALRAJ-PC;Initial catalog=csvtest;user id=sa;password=root");
con.Open();
StreamReader sr = new StreamReader("D:\test.csv");
string line;
string SQL="insert into[data1]([name],[age])values(@name,@age)";
while((line=sr.ReadLine())!=null)
{
SqlCommand cmd = new SqlCommand(SQL,con);
cmd.Parameters.AddWithValue("@name",line[0]);
cmd.Parameters.AddWithValue("@age", line[1]);
cmd.ExecuteNonQuery();
}
con.Close();
}
}