I want to upload a text file and get the data of that text file into a table of database . I m using Sql Server 2000 , and working in c#. kindly can you help me doing this and if possible can you give me the code for this

Recommended Answers

All 5 Replies

Use Control called "Upload File" in Web-Based application (ASP.NET) then read uploaded file save its text into DB.

thanks for the reply i have uploaded the text file but i cannot download the data of that text file into the table of my database . kindly can you tell me how to read the data of the text file from internet and save its data into database .

You've the file in your hand, use File.ReadAllText("FilePathOnYourServer") which returns string, take it and using Insert statement your string'll be in your DB.

sir I uploaded the file using vb . But I wanna upload using C# .I m writing the following code private void btnUpload_Click(object sender, EventArgs e)

{
            WebClient Client = new WebClient();
            Client.UploadFile("http://localhost/imp.txt","C:\\Documents and Settings\\Maverick\\Desktop\\imp.txt");
        }

but an error message is comming

"The remote server returned an error: (405) Method Not Allowed."
kindly tell me what to do

Check the credential and permissions to do server calls, you can modifiy or add creadentials attributes into the server side method to avoid such trouble

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.