CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 7/1/2008 5:55:22 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 18 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
"dotnet_bug" <>
NewsGroup User
populate database with xls file uploading7/1/2008 5:55:22 AM

0

 

hii all,

        i need to populate my database by xls file, means when i upload xls file thru file uploading system, my database shud be populated with the values in xls file and old data shud be removed first. first of all i tried to make a folder like given below...

string MyPath;

string MyName;

// Display the names in D:\ that represent directories.

 

MyPath = "D:\\debit_credit\\";

// Set the path.

MyName = FileSystem.Dir(MyPath, Constants.vbDirectory);

 

// Retrieve the first entry.

 

if (MyName == "")

{

// The folder is not there & to be created

FileSystem.MkDir("D:\\debit_credit\\");

//Folder created

}

but i'm getting error :- The type or namespace name 'FileSystem' could not be found (are you missing a using directive or an assembly reference?)


can any one tell me the complete solution???

 Regards

Anant

"GillouX" <>
NewsGroup User
Re: populate database with xls file uploading7/1/2008 8:34:05 AM

0

 I think to use FilseSystem you need to use this

 

using Microsoft.VisualBasic;

 


  

"Punithkumar" <
NewsGroup User
Re: populate database with xls file uploading7/1/2008 8:42:18 AM

0

Try this code. 

// Connection String to Excel Workbook
string excelConnectionString = @"Provider=Microsoft
    .Jet.OLEDB.4.0;Data Source=Book1.xls;Extended
    Properties=""Excel 8.0;HDR=YES;"""
;

// Create Connection to Excel Workbook
using (OleDbConnection connection =
             new OleDbConnection(excelConnectionString))
{
    OleDbCommand command = new OleDbCommand
            ("Select ID,Data FROM [Data$]", connection);

    connection.Open();
   
    // Create DbDataReader to Data Worksheet
    using (DbDataReader dr = command.ExecuteReader())
    {
        // SQL Server Connection String
        string sqlConnectionString = "Data Source=.;
           Initial Catalog=Test;Integrated Security=True"
;

        // Bulk Copy to SQL Server
        using (SqlBulkCopy bulkCopy =
                   new SqlBulkCopy(sqlConnectionString))
        {
            bulkCopy.DestinationTableName = "ExcelData";
            bulkCopy.WriteToServer(dr);
        }
    }
}


Regards,
Punithkumar
"Thomas Sun – M
NewsGroup User
Re: populate database with xls file uploading7/4/2008 4:02:25 AM

0

dotnet_bug:

but i'm getting error :- The type or namespace name 'FileSystem' could not be found (are you missing a using directive or an assembly reference?)
can any one tell me the complete solution???

Hi,

Did your project add reference to 'FileSystem'? If not, I guess you want to create directory using the Directory.CreateDirectory method under System.IO Namespace.

In your case, you can create directory in the server and save the Excel file, which is uploaded, into this directory, and then insert this Excel file's data into database just as Punithkumar replied above. You might need to delete the old data from database before inserting new data.

For more information about creating directory, see http://msdn.microsoft.com/en-us/library/54a0at6s(VS.80).aspx

For more information about uploading file, see http://msdn.microsoft.com/en-us/library/aa479405.aspx

 

I hope this helps.


Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:













stylesheet not working

visual studio 2008 and ajax problem

debugging in vs 2008 vs 2005

very slow vs2008 editor

insert, delete, update is not availabe in advance menu (visual web developer 2008

ajax problem

js debugging does not work (vs2008 beta2)

question on javascript debuggin.

remote debugging

problems with placing controls on a page .

how to sort tabs in toolbox of vs 2008?

how to disable autosave after add web reference in visual studio 2008

2 years msdn subscription for $1000 - is it "legal" ?

user control's class?

iis6.0 deployment?

whats wrong with vs 2008?

my visual studio version

error only in visual studio 2008 for custom sqlpersonalization provider but works well in 2005

error running in vs 2008

fonts in "design view"

hidden divs in vs 2008

avoid have x no. of developer server start up at debug

.net 3.5 and vs 2008

vs 2008 problem - negating the minimum value of a twos complement number is invalid.

translating german script into english?

advover vs2008 over vs2005

multi-targeting support today

wpf browser application

where is the xaml designer?

help! webdev.webserver error

does the unit test wizard work with web-sites converted from asp.net 2.0?

launching project in debug mode on vs2008 leaves ie hanging

hxmerge error at the end of the installation

visual studio 2005 project in visual studio 2008 without conversion

labels positioning

solution with .mdb, on a computer without sql express

would there be issues if i use visual studio 2008 express on my asp .net 2.0 sites?

ajax extensions scriptmanager missing

object reference not set to an instance of an object

installing orcas beta 1 on existing system with visual studio 2005?

vs 2008 ide - splitter bar (located above the scroll bar)

download page unprofessional

"go to reflector" option inside visual studio not working

whats the difference between web site creation and web application creation in dotnet 2.0

question before i upgrade my solutions to '08 from '05

is there an architect or enterprise architect version of visual studio 2008

javascript intellisense support for external libraries, e.g. prototype, jquery,...

ajax control extender - no javascript intellisense support

error adding object to linq to sql class

the project type is not supported by this installation

   
  Privacy | Contact Us
All Times Are GMT