homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

Connecting to Mysql remote server using asp:Fileupload

5+ Year Member

Msg#: 4306682 posted 9:57 pm on May 1, 2011 (gmt 0)

Using asp:FileUpload I am trying to upload a file to my remote MySql database.(Table Name:files: Field Name filename.) But canít figure out the correct connection code and how to insert into the below FileUpload code.

My current connect which works with other applications is located in web.config:
<add name="ConnStringName" connectionString="Database=#*$!xx_data;Data Source=xx.#*$!.xx.x;port=#*$!x;UId=#*$!#*$!x;Password=#*$!#*$!;"
providerName="MySql.Data.MySqlClient" />

FileUpload code:

<script type="text/vbscript" runat="server">
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
If FileUpload1.HasFile Then
FileUpload1.SaveAs("C:\Uploads\" & _
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Label1.Text = "You have not specified a file."
End If
End Sub

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Upload Files</title>
<form id="form1" runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Upload File" />&nbsp;<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
I am locating the file to be uploaded via the browse button.

Help would be appreciated.




WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

Msg#: 4306682 posted 1:56 pm on May 2, 2011 (gmt 0)

Exploring MySQL in the Microsoft .NET Environment [dev.mysql.com] Shows a couple of ways of setting up the Data Connection coding to work with MYSQL depending which Library you use to connect with.

As for the file uploading part. Are you trying to upload the file into the database? or are you just trying to save the path to the uploaded file in the database?


5+ Year Member

Msg#: 4306682 posted 3:28 pm on May 2, 2011 (gmt 0)

Thank for your reply and suggested lnk.

I am trying to create a form to upload selected file(s) direct to my database by clicking an upload button.


WebmasterWorld Senior Member 10+ Year Member

Msg#: 4306682 posted 3:07 pm on May 9, 2011 (gmt 0)

Before trying to write anything to the DB, I would make sure I can connect okay to it by reading something from the DB first.

If I'm not mistaken, not all servers let you connect remotely to a mysql db - sometimes you have to set some permissions.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved