4
Answers

How to upload file with name,Type,size to sql server?

selva kumar

selva kumar

11y
928
1
Hi friends i want to upload the file(Pdf/word) to database With Filename,Type,Size.Can any one give me the correct reference..

Thanks in advance.........
Answers (4)
3
Nainil
NA 660 0 15y

.NET:   
   string
userString = textBox1.Text;
   string replacedString = userString.Replace("'", "''");
 
SQL:
   replacedString = Replace(userString,"'","''")
 
Hope this helps.
Accepted
1
Nainil
NA 660 0 15y

Hi Giorgio,
    Whenever you have single quotes, replace them with 2 single quotes. That should work.
0
Gustavo
NA 1.8k 386.6k 15y

Nainil:
 
Yes, thank you.
0
Gustavo
NA 1.8k 386.6k 15y

Nainil:
 
Can you give me a sample code of the 2 types?
 
0
Nainil
NA 660 0 15y

Giorgio,
   You can either use .NET string.Replace() method to replace any single quotes with 2 single qoutes or you can use T-SQL's Replace function. Since the value being inserted is passed in as a SqlParameter.Value property, you can run the Replace function through it and ensure that any string being passed to the stored procedure is clean. Hope this helps.
0
Gustavo
NA 1.8k 386.6k 15y

Nainil:
 
Yes, if it was a string. But it will be some text that the user entered. Is there a way to do it automatically when I put it into the sql command to save it?