Rijen Juni

Rijen Juni

  • NA
  • 16
  • 7.1k

Excel file to SQL server using Entity Framework

Aug 19 2015 9:57 PM
i try to passing data from .xls file to sql server but its still not working the error messages says Keyword not support metadata, I'm using Entity Framework its my code;
 
 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
{ string conn = ConfigurationManager.ConnectionStrings["BaruEntities"].ConnectionString;
 SqlConnection con = new SqlConnection(conn);
 string query = "Insert into TrashExcel(No Pin,Nama, No HP,Tgl Lahir, No KTP)
 Values('" + ds.Tables[0].Rows[i][0].ToString() + "','" + ds.Tables[0].Rows[i][1].ToString() + "','" + ds.Tables[0].Rows[i][2].ToString() + "','" + ds.Tables[0].Rows[i][3].ToString() + "','" + ds.Tables[0].Rows[i][4].ToString() + "')";
con
.Open(); SqlCommand cmd = new SqlCommand(query, con);
cmd
.ExecuteNonQuery();
con
.Close();
If you have solution for this please tell me and I'll appreciate it Thanks


Answers (1)