473,569 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim con As OleDbConnection

Dim strFile As HttpPostedFile

strFile = inpFileField.Po stedFile

con = New OleDbConnection ("PROVIDER=Micr osoft.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 1130
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
if file.PostedFile .ContentLength > 0 then
dim path as string = "c:\myserver\so meRepository\" +
System.IO.Path. GetFileName(fil e.PostedFile.Fi leName)
file.PostedFile .SaveAs(path)

dim connectionStrin g as string = "Provider=Micro soft.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_chief12 3101@NoSpam_yah oo.com> wrote in message
news:jI******** ************@co mcast.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim con As OleDbConnection

Dim strFile As HttpPostedFile

strFile = inpFileField.Po stedFile

con = New OleDbConnection ("PROVIDER=Micr osoft.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******** ******@TK2MSFTN GP14.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
if file.PostedFile .ContentLength > 0 then
dim path as string = "c:\myserver\so meRepository\" +
System.IO.Path. GetFileName(fil e.PostedFile.Fi leName)
file.PostedFile .SaveAs(path)

dim connectionStrin g as string =
"Provider=Micro soft.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_chief12 3101@NoSpam_yah oo.com> wrote in message
news:jI******** ************@co mcast.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim con As OleDbConnection

Dim strFile As HttpPostedFile

strFile = inpFileField.Po stedFile

con = New OleDbConnection ("PROVIDER=Micr osoft.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
8666
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 my package. I don't want to hardcode any path and I would like to be independent of the application server (tomcat, websphere,...). Until now, I...
1
13688
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: /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5 I am using Perl 5.6.1 in HPUX 11. Any hints?
0
8988
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 bugzilla 'checksetup.pl' file, I get the following: -------------------------------------------------------------------
0
1325
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 alias mechanism for XML namespace redirection. If the host file on a client machine has the entry; 192.168.1.12 XML-srv
0
1274
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 network share, application display error message: Server Error in '/MYAPP' Application....
7
10874
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. Only needs to work in Unix, but would be interesting if it was cross-platform. Thanks.
3
3070
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. If the URL link to the web page is mailed to someone and they click on the link in Outlook and there are no web browsers already opened on their...
1
2018
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 lock situation. So i tried to put flock here in the following code. But i got the following error. Can't locate object method "fd" via package...
1
8865
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 { install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.