TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
raj kadam
NA
92
7.5k
Importing Access Database fil into SQL Server 2012 using c#
Apr 4 2015 6:15 AM
public void importdatafromexcel(string excelfilepath)
{
//string ssqltable = "tdatamigrationtable";
//string myexceldataquery = "select id,p_name,city from [medi1$]";
string excelconnectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=medi1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
using (OleDbConnection connection = new OleDbConnection(excelconnectionstring))
{
OleDbCommand command = new OleDbCommand("Select id,p_name,city FROM [medi1$]", connection);
connection.Open();
using (DbDataReader dr = command.ExecuteReader())
{
string sqlconnectionString = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
using (SqlBulkCopy bulkCopy =
new SqlBulkCopy(sqlconnectionString))
{
bulkCopy.DestinationTableName = "ExcelData";
bulkCopy.WriteToServer(dr);
}
}
}
Reply
Answers (
1
)
How to use checkbox control within checkbox list control
Change database datetime column value in tmrTimer_Tick event