Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Locate File Diologe

Reply
Thread Tools

Locate File Diologe

 
 
Reggie
Guest
Posts: n/a
 
      06-17-2005
HI and TIA! What I'm trying to do is have my user click a button which
opens the find file dialogue box. Once they find it I want to place the
full path into a variable so that I can use it as the Source in my
connection string. I've tried the HTML File Field control which allows me
to navigate to the .mdb file and it places it into the File Field control on
my page, however every attempt I try to place it in a variable gives me an
error stating that the Page can't be located. I want something like so:


Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim con As OleDbConnection

Dim strFile As HttpPostedFile

strFile = inpFileField.PostedFile

con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA
Source=strFile")

con.Open()

End Sub

Any help is appreciated. Thanks for your time!
--

Reggie


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      06-17-2005
Reggie:
A couple thing. The MDB file would be on the client's machine, so you'd
want them to upload the file to the server, save it on the server and then
use the saved path to which you'll open a connection, right? For example,
if I'm on your site and point to an mdb file on my computer, you won't be
able to access the file as c:\karl\myfile.mdb. You'll need to save the file
on your server and access it there. I say this because that doesn't seem to
be what you are doing....

secondly, if you have <input type="file" runat="server" strFile" /> in your
page, you should declare protected strFile as HttpPostFile in your class.
Not in the function, and it must be protected.

Here's a function which makes more sense to me...haven't tried it, just
giving you some ideas:

in yoru aspx:
<input type="file" runat="server" id="file" />

in your codebehind:

public class XXX
inherits page

protected file as HttpPostFile

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
if file.PostedFile.ContentLength > 0 then
dim path as string = "c:\myserver\someRepository\" +
System.IO.Path.GetFileName(file.PostedFile.FileNam e)
file.PostedFile.SaveAs(path)

dim connectionString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" "& path
'rest of the connection stuff here

end if
end sub

hope that helps,
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Reggie" <NoSpam_chief123101@NoSpam_yahoo.com> wrote in message
news:(E-Mail Removed)...
> HI and TIA! What I'm trying to do is have my user click a button which
> opens the find file dialogue box. Once they find it I want to place the
> full path into a variable so that I can use it as the Source in my
> connection string. I've tried the HTML File Field control which allows me
> to navigate to the .mdb file and it places it into the File Field control
> on my page, however every attempt I try to place it in a variable gives me
> an error stating that the Page can't be located. I want something like
> so:
>
>
> Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Dim con As OleDbConnection
>
> Dim strFile As HttpPostedFile
>
> strFile = inpFileField.PostedFile
>
> con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA
> Source=strFile")
>
> con.Open()
>
> End Sub
>
> Any help is appreciated. Thanks for your time!
> --
>
> Reggie
>



 
Reply With Quote
 
 
 
 
Reggie
Guest
Posts: n/a
 
      06-18-2005
Karl, Exactly what I'm looking for. Knew what I wanted to do just didn't
know how to go about getting it done. Thanks very much for you time.

--

Reggie
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:(E-Mail Removed)...
> Reggie:
> A couple thing. The MDB file would be on the client's machine, so you'd
> want them to upload the file to the server, save it on the server and then
> use the saved path to which you'll open a connection, right? For example,
> if I'm on your site and point to an mdb file on my computer, you won't be
> able to access the file as c:\karl\myfile.mdb. You'll need to save the
> file on your server and access it there. I say this because that doesn't
> seem to be what you are doing....
>
> secondly, if you have <input type="file" runat="server" strFile" /> in
> your page, you should declare protected strFile as HttpPostFile in your
> class. Not in the function, and it must be protected.
>
> Here's a function which makes more sense to me...haven't tried it, just
> giving you some ideas:
>
> in yoru aspx:
> <input type="file" runat="server" id="file" />
>
> in your codebehind:
>
> public class XXX
> inherits page
>
> protected file as HttpPostFile
>
> Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> if file.PostedFile.ContentLength > 0 then
> dim path as string = "c:\myserver\someRepository\" +
> System.IO.Path.GetFileName(file.PostedFile.FileNam e)
> file.PostedFile.SaveAs(path)
>
> dim connectionString as string =
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" "& path
> 'rest of the connection stuff here
>
> end if
> end sub
>
> hope that helps,
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
>
> "Reggie" <NoSpam_chief123101@NoSpam_yahoo.com> wrote in message
> news:(E-Mail Removed)...
>> HI and TIA! What I'm trying to do is have my user click a button which
>> opens the find file dialogue box. Once they find it I want to place the
>> full path into a variable so that I can use it as the Source in my
>> connection string. I've tried the HTML File Field control which allows
>> me to navigate to the .mdb file and it places it into the File Field
>> control on my page, however every attempt I try to place it in a variable
>> gives me an error stating that the Page can't be located. I want
>> something like so:
>>
>>
>> Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>>
>> Dim con As OleDbConnection
>>
>> Dim strFile As HttpPostedFile
>>
>> strFile = inpFileField.PostedFile
>>
>> con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA
>> Source=strFile")
>>
>> con.Open()
>>
>> End Sub
>>
>> Any help is appreciated. Thanks for your time!
>> --
>>
>> Reggie
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Locate and Read specific values from file Gol Yass Java 1 10-10-2006 08:14 AM
Is there a tool to locate duplicate lines in a file ? rofarmer Software 0 08-17-2006 05:58 PM
How do I Locate an application properties file MattC Java 4 09-17-2005 11:46 PM
Using Hosts file to locate schema for validation shawnk XML 0 04-29-2005 02:16 PM
Can aspx file use PATH variable to locate dlls iana_kosio@yahoo.com ASP .Net 1 04-08-2005 09:33 PM



Advertisments