Using the Data Adapter Configuration Wizard

J

Jim Brown

I have been trying to design a Web Form using VB.Net 2002 that uses a
DataGrid to display a MS Access database.



When using the Data Adapter Configuration Wizard on my local server I
successfully make a "New Connection" after pointing it to the Access MDB
file on my local file system. But when I try to duplicate this on my live
web server I can't figure out what to put in for the path to my database.



Can I use the wizard or do I have to build the OleDbConnection's DataSource
string manually as my web page loads?



Live site is hosted at Microsoft bCentral
 
M

Miha Markic [MVP C#]

Hi Jim,

You should set OleDbConnection.ConnectionString properly - you might store
the connection string in web.config file and read it:
web.config:
<?xml version="1.0" encoding="windows-1250"?>
<configuration>
...
<appSettings>
...
<add key="YourStringKey" value="connection string"/>
....
< /appSettings>
...
</configuration>

Code:
oleDbConnection.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings["YourStringKey"];
 
M

Maxim V. Karpov

Jim,
If you use Data Adapeter Wizard than Connection object is created for you
inside of the Designer. If you click on the properties of the object you
will see DynamicProperty, simply select ConnectionString. It will generate
entry for your web.config or app.config file that you can modify later. With
this approach you do not have to write any code.

Maxim

[www.ipattern.com do you?]
 
J

Jim Brown

OK, now I get it. I can point towards a local hard drive copy of my
database to get through the wizard. Then I set the DynamicProperty as
you say so a key gets added to my web.config in the <appSettings>.

I was able to use the Server.Mathpath function to determine the actual
path to my live web server. I hard coded that in the web.config's copy
of the key noted above and all seems to work.

I wound up with this (except that 111.222.333.444 is not the actual IP
address):
\\111.222.333.444\files6\191\applicationsplus.com\web\dotnet\vbtest\db\webdata.mdb

Everything after the \applicationsplus.com makes sense to me as that's
the folder paths in my site. I'm sure that the pieces before could
change if my web host moves my site to another of their servers. So my
next question: is there a better way of coding this into the
web.config file?


Jim,
If you use Data Adapeter Wizard than Connection object is created for you
inside of the Designer. If you click on the properties of the object you
will see DynamicProperty, simply select ConnectionString. It will generate
entry for your web.config or app.config file that you can modify later. With
this approach you do not have to write any code.

Maxim

[www.ipattern.com do you?]
Jim Brown said:
I have been trying to design a Web Form using VB.Net 2002 that uses a
DataGrid to display a MS Access database.



When using the Data Adapter Configuration Wizard on my local server I
successfully make a "New Connection" after pointing it to the Access MDB
file on my local file system. But when I try to duplicate this on my live
web server I can't figure out what to put in for the path to my database.



Can I use the wizard or do I have to build the OleDbConnection's DataSource
string manually as my web page loads?



Live site is hosted at Microsoft bCentral
 
J

Jim Brown

OK, now I get it. I can point towards a local hard drive copy of my database
to get through the wizard. Then I set the DynamicProperty as you say so a
key gets added to my web.config in the <appSettings>.

I was able to use the Server.Mathpath function to determine the actual path
to my live web server. I hard coded that in the web.config's copy of the key
noted above and all seems to work.

I wound up with this (except that 111.222.333.444 is not the actual IP
address):
\\111.222.333.444\files6\191\applicationsplus.com\web\dotnet\vbtest\db\webda
ta.mdb

Everything after the \applicationsplus.com makes sense to me as that's the
folder paths in my site. I'm sure that the pieces before could change if my
web host moves my site to another of their servers. So my next question: is
there a better way of coding this into the web.config file?



Maxim V. Karpov said:
Jim,
If you use Data Adapeter Wizard than Connection object is created for you
inside of the Designer. If you click on the properties of the object you
will see DynamicProperty, simply select ConnectionString. It will generate
entry for your web.config or app.config file that you can modify later. With
this approach you do not have to write any code.

Maxim

[www.ipattern.com do you?]
Jim Brown said:
I have been trying to design a Web Form using VB.Net 2002 that uses a
DataGrid to display a MS Access database.



When using the Data Adapter Configuration Wizard on my local server I
successfully make a "New Connection" after pointing it to the Access MDB
file on my local file system. But when I try to duplicate this on my live
web server I can't figure out what to put in for the path to my database.



Can I use the wizard or do I have to build the OleDbConnection's DataSource
string manually as my web page loads?



Live site is hosted at Microsoft bCentral
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top