473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Locate File Diologe

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
Nov 19 '05 #1
2 1119
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:jI********************@comcast.com...
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

Nov 19 '05 #2
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:eG**************@TK2MSFTNGP14.phx.gbl...
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:jI********************@comcast.com...
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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Kienzle | last post by:
I'm new to Java programming. I'm developing a Servlet for tomcat which needs an external configuration file. With external I mean a file (in XML format) which is customizable and not contained in...
1
by: Andrew | last post by:
Dear Experts, I have a perl program that using Getopt:Std module, when I try to run the GetOpt program, the following error returned: Can’t locate Getopt.pm in @INC (@INC contains:...
0
by: packrat | last post by:
I am attempting to build a Bugzilla server on OS X. All of this is new to me, working with the Perl, MySQL, and Bugzilla, so I have been banging my head often. Software error: When I run the...
0
by: shawnk | last post by:
I want to use the Hosts file to locate schema for validation. The Hosts file (C:\Windows\System32\etc) will locate xsd schema files on a LAN server for development purposes. This gives me a...
0
by: sp1dEr | last post by:
Hi all, I have an asp.net application (framework 1.1 sp1) on windows server 2003. When the document root is locate in local that's all ok... but if the document root is locate on locate on...
7
by: mwt | last post by:
Is there a function in python that does what "locate" does in a bash shell? I know I could do it by using os.popen('locate'), but I'm curious if there's a Python "native" way to go about it....
3
by: Jason | last post by:
Hi, I built a vb.Net application that creates ICS calendar files dynamically and then sends them to the client browser as a downloadable file. Works perfectly except in the following situation....
1
by: perlvasu | last post by:
6 jobs are running at the same time and accessing same dbm file for writing and reading. These are daily jobs and failing only some times not regularly. So i thought of this is just because of dead...
1
by: chaosbuddha | last post by:
Hi! I am trying to set-up mysql-zrm to take backups of a remote mysql server. The mysqlhotcopy command is throwing up the following error: Output of command: 'mysqlhotcopy' is { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.