need help in c# .net uploadFile control

asp.net , csharp , db Quebec, Canada
  • 12 years ago

    hi

    i am using asp.net c# can someone guide me how i can store uploaded file in sql server 2005 .i can upload a file and save it in hard drive using this code! now i want to save uploaded files in SQL server like .doc files etc.Kindly guide me what can i do for this?

    Code :

    if (absFile.PostedFile.FileName == "")

    {

    Label1.Text =
    "Error ! Plz Select a File ";Label1.ForeColor = System.Drawing.Color.Azure;

    }

    else

    {

     

    absFile.PostedFile.SaveAs(
    "C:\\User-File.doc");

    }

  • 12 years ago

    Take a look at this thread and see if it helps you. 

    http://www.developerfusion.co.uk/forums/t/53618/

     

  • 12 years ago

    hi

    i can upload the file and also its path display on the list box control .i try to save the file path in sql and try to show it in Grid view all my data(in other text boxes and controls )save but file path not save and even not store the null in DB .nothing is display only blank space.i dont no either mistake in data type or in code .the data type i choose to store the path is nvarchar(50) and the c#.net code is

      

    command.Parameters.AddWithValue("@File", File_Up.Value);

    kindly guide me what is the mistake

  • 12 years ago

    Without seeing more code, I can't really say what's wrong. What is the SQL for the 'Insert command' that you've created to save the file path into database?

  • 12 years ago
    hi
  • 12 years ago

    my problem is solve actually i was save file path and file itself through different buttons now i do my task with single insert Botton now my file path save in SQL and also display path in grid view

    thanks any way i found u a most kind and helpfull resource Smiley Face

  • 12 years ago

    Glad it's working and thanks for the complement :-) 

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.”