2
  • My team working in asp.net projects
  • Here we have to upload Excel contents to Database
  • We are using linq
  • Please help to do the same

2 Answers 2

3

http://weblogs.asp.net/rajbk/archive/2010/02/20/uploading-and-storing-files-in-sql-using-asp-net.aspx

http://weblogs.asp.net/rajbk/archive/2009/05/02/uploading-an-excel-file-to-sql-through-an-asp-net-webform.aspx

Sign up to request clarification or add additional context in comments.

Comments

0

2 easy ways without using LINQ:

using System.IO;
using System.Data;
using System.Data.OleDb;

public DataRow[] GetUsers(string path, string id) { DataTable dt = new DataTable(); if (File.Exists(path)) { using (OleDbConnection con = new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0", path))) { OleDbDataAdapter da = new OleDbDataAdapter(string.Format("select * from users", id), con); da.Fill(dt); } } string expression = String.Format("{0} = '{1}' and {2} <> ''", id, "first_name", "last_name"); string sort = "last_name ASC"; return dt.Select(expression, sort); }

public DataTable GetUsers(string path, string id) { DataTable dt = new DataTable(); if (File.Exists(path)) { using (OleDbConnection con = new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0", path))) { string expression = String.Format("{0} = '{1}' and {2} <> ''", id, "first_name", "last_name"); OleDbDataAdapter da = new OleDbDataAdapter(expression, con); da.Fill(dt); } } return dt; }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.