Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using the Data Adapter Configuration Wizard

0 views
Skip to first unread message

Jim Brown

unread,
Jan 30, 2004, 11:43:38 PM1/30/04
to
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


Miha Markic [MVP C#]

unread,
Jan 31, 2004, 4:18:06 AM1/31/04
to
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"];

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Jim Brown" <j...@applicationsplus.com> wrote in message
news:%23ElxqR7...@TK2MSFTNGP11.phx.gbl...

Maxim V. Karpov

unread,
Jan 31, 2004, 9:21:04 AM1/31/04
to
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" <j...@applicationsplus.com> wrote in message
news:%23ElxqR7...@TK2MSFTNGP11.phx.gbl...

Jim Brown

unread,
Jan 31, 2004, 11:50:19 AM1/31/04
to
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 Brown

unread,
Jan 31, 2004, 11:54:01 AM1/31/04
to
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" <m...@ipattern.com> wrote in message
news:uxn2aRA6...@tk2msftngp13.phx.gbl...

0 new messages