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: 11 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:













table or webparts?

how to create a new empty text file?

try ... catch structure in a web application

why are the all the attributes of the tag not showing?

good doc on structure of sessionid itself?

compile a .cs file without vs.net?

sql data clash

command.open()/connection.open()

what are the different types of testing??

working with dates

is it possible to pass an array() to a class method?

how to use a button to call a new page

saving an email copy when sending mail using mailmessage

escape and urlencode

ssi

sqlcommandbuilder

trying to read csv file

[*-)] asp.net application compatibility with linux and mac os

strange try/catch error

default page not working when some code is removed

auto incrementing varchar variable using asp.net

problem on setting a global object for an asp.net application.

can asp.net 3.5 and classic asp be on same server?

vs.net 2003 problems (or my misunderstanding)

where is that starter kit of version 1.1

value of type 'system.data.dataset' cannot be converted to string

ie7 and visual studio

controlling a li item

code for sending one datagrid through mail in asp.net using vb.net 2003?

appending a new line at specified location in a text file

the supportspartialrendering property cannot be changed after the init event.

enable urlmappings on the windows server 2003, hrlp!

the role provider feature in whidbey

adding carriage return to excel file

disabling validation in an user control.

unable to access class files in saperate folders

hyperlink on each item of radiobutton

querystring problem

continue shopping button

grocertogo.mdb

multisheet excel spreadsheet

asp.net application architechture

general questions..

gridview detailview update paging

do i need a session variable?

navigateurl='#'

c# and xml element attributes

password recovery - insert password into html template

can you referer to <asp:textbox from client code.

changing the <identity impersonate="true" /> in web.config breaks the compiler

   
  Privacy | Contact Us
All Times Are GMT