C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

plz telme any


Posted Date: 17 Oct 2008      Posted By: mahesh      Member Level: Silver     Points: 1   Responses: 3



how to upload a image into mysql using asp.net with vb




Responses

Author: satyavani.namburu    17 Oct 2008Member Level: BronzeRating:     Points: -20

Sub UploadImage()
If Not (fileupload1.PostedFile Is Nothing) Then 'Check to make sure we actually have a file to upload

Dim strLongFilePath As String = fileupload1.PostedFile.FileName
Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "\")
Dim strFileName As String = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)

Select Case fileupload1.PostedFile.ContentType
Case "image/pjpeg", "image/jpeg" 'Make sure we are getting a valid JPG image
fileupload1.PostedFile.SaveAs(Server.MapPath("\") & strFileName)
lbStatus.Text = strFileName & " was uploaded successfully to: " & Server.MapPath("\") & strFileName
Case Else
'Not a valid jpeg image
lbStatus.Text = "Not a valid jpeg image"
End Select
End If

End Sub



Author: satyavani.namburu    17 Oct 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

http://www.easerve.com/developer/tutorials/asp-net-tutorials-upload-image-file.aspx


Author: Usha R    17 Oct 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

hi..

this s the sample code in c#..

u convert and write it in vb..

static byte[] pic;

string str = "Update tablename set Imgfield=@pic where ProdId='" + txtprodid.Text + "'";

SqlCommand command = new SqlCommand(str, Connection);
int len = FileUpload1.PostedFile.ContentLength;
pic = new byte[len];
int psize = len / 1024;
if (psize < 512)
{
FileUpload1.PostedFile.InputStream.Read(pic, 0, len);
command .Parameters.Add("@pic", pic);
command .ExecuteNonQuery();
}


have a nice day...

Thanks & Regards
Usha



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : How can I set printer settings (like setting Landscape, margins etc.) using javascript ...
Previous : What is wrong with this code?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use