homepage Welcome to WebmasterWorld Guest from 50.17.176.149
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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
latoc




msg:4306684
 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
Try
FileUpload1.SaveAs("C:\Uploads\" & _
FileUpload1.FileName)
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Upload Files</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<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>
</form>
</body>
</html>
I am locating the file to be uploaded via the browse button.

Help would be appreciated.

latoc

 

Ocean10000




msg:4306924
 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?

latoc




msg:4306956
 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.
latoc

defanjos




msg:4309869
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved