Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Monday, March 26, 2012

The connection name ConnectionString was not found in the applications configuration or th

Hi All, I need help. I am developing a very simple ASP.NET Application that retreived some information from an Oracle Database.

The application was working fine, but suddenly it stopped working with the following exception:

"The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty."

Furthermore, I had backups of the application on my hard drive, and all suddenly stopped working with the same exception. I beieve it is a general Configuration issue ... because all the connections are failing with the same exception.

Following is the excepton, and the line where the exception is given:

Line 55:
Line 56:
Line 57: <asp:SqlDataSource ID="SqlDataSource42" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString42%>"
Line 58: ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
Line 59: SelectCommand="Select * from TBORDER_ACTION where customer_id = 'XYZ'">

And again the exception is "The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty."

Following is my Web.config:

<?xmlversion="1.0"?><!--

Note: As an alternative to hand editing this file you can use the

web admin tool to configure settings for your application. Use

the Website->Asp.Net Configuration option in Visual Studio.

A full list of settings and comments can be found in

machine.config.comments usually located in

\Windows\Microsoft.Net\Framework\v2.x\Config

-->

<configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<addname="ConnectionString42"connectionString="Data Source=DatabaseInstance;User ID=Username42;Password=Password42;Unicode=True"providerName="System.Data.OracleClient" />

<addname="ConnectionString42m"connectionString="Data Source=DatabaseInstance;User ID=Username;Password=Password42;Unicode=True"

providerName="System.Data.OracleClient" />

</connectionStrings>

<system.web>

<!--

Set compilation debug="true" to insert debugging

symbols into the compiled page. Because this

affects performance, set this value to true only

during development.

Visual Basic options:

Set strict="true" to disallow all data type conversions

where data loss can occur.

Set explicit="true" to force declaration of all variables.

-->

<compilationdebug="true"strict="false"explicit="true"/>

<pages>

<namespaces>

<clear/>

<addnamespace="System"/>

<addnamespace="System.Data"/>

<addnamespace="System.Collections"/>

<addnamespace="System.Collections.Specialized"/>

<addnamespace="System.Configuration"/>

<addnamespace="System.Text"/>

<addnamespace="System.Text.RegularExpressions"/>

<addnamespace="System.Web"/>

<addnamespace="System.Web.Caching"/>

<addnamespace="System.Web.SessionState"/>

<addnamespace="System.Web.Security"/>

<addnamespace="System.Web.Profile"/>

<addnamespace="System.Web.UI"/>

<addnamespace="System.Web.UI.WebControls"/>

<addnamespace="System.Web.UI.WebControls.WebParts"/>

<addnamespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

<!--

The <authentication> section enables configuration

of the security authentication mode used by

ASP.NET to identify an incoming user.

--> <authenticationmode="Windows"/>

<!--

The <customErrors> section enables configuration

of what to do if/when an unhandled error occurs

during the execution of a request. Specifically,

it enables developers to configure html error pages

to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

--> </system.web>

</configuration>

Please help; I have been stuck with this issue for 1 week...

You have two connections strings with the same name. Is that the problem?


No - I have 2 connection string with 2 different names.

Please advice,

Mahdi


Line 57: <asp:SqlDataSource ID="SqlDataSource42" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString42%>"
Line 58: ProviderName="<%$ ConnectionStrings:ConnectionString42.ProviderName %>"



Dear jfmccarthy,

You are number 1; You are the best. I have been trying 3 days to find an answer, explored many sites, and spent more than 30 hours but could not find the answer.

Your suggestion was correct. I want to realyyyy... thank you, and wish you much success in your life (Although I am sure you are successfull).

Thanks Thanks Thanks...Big Smile


Well thank you very muchEmbarrassed

The connection is already Open (state=Open, Fetching).

Hello again.

This problem relates to a Business Object that I've created. I get the above error when I try t call a Sub within the business object that inserts into the database. I have various other Subs and Functions that Select from the database and they don't seem to have a problem. I can't see where the connection is being left open... But I've been staring at this all day now so theres a good chance I'm missing something obvious...

The VB for the business object is below. The sub in the aspx page that calls it is:

Sub Button1_Click(Source As Object, E As EventArgs)
dim objForum as New BidwellsDevelopments.PublicForum
objForum.ReplyToForum(pubThreadID, pubUser,oEdit1.Content)
End Sub

And the business object code (the sub in question is at the bottom in bold):

' VB Document
Imports System
Imports System.Data
Imports System.Data.OleDb

Namespace BidwellsDevelopments

Public Class DevelopmentDetails
public DevelopmentID as Integer
public Name' as string
public Description' as string
public Keywords' as string
'public Live' as integer
public Logo' as string
public MainImage' as string
public HomePage' as string
public PostCode' as string
public Address1' as string
public Address2'' as string
public Address3' as string
public Town' as string
public County' as string
public Country' as string
'' public ClientID' as integer
' public ManagerID' as integer
' public CreatorID' as integer
End Class

Public Class Development
Private objConn as new OleDbConnection (System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))

public function GetDevelopment(developmentID) as DevelopmentDetails


Dim objCmd As New OleDbCommand("spGetDevelopment", objConn)
objCmd.CommandType = CommandType.StoredProcedure

Dim objParam As New OleDbParameter("@dotnet.itags.org.DevelopmentID", OleDbType.Char)
objParam.Value = developmentID
objCmd.Parameters.Add(objParam)
Dim objReader as OleDbDataReader

try
objConn.Open()
objReader = objCmd.ExecuteReader
catch ex as OleDbException
throw ex
end try
dim objDetails as new DevelopmentDetails

while objReader.Read()
objDetails.DevelopmentID = developmentID
objDetails.Name = objReader(1)
objDetails.Description = objReader(2)
objDetails.Keywords = objReader(3)
'objDetails.Live = objReader.GetInt32(4)
objDetails.Logo = objReader(5)
objDetails.MainImage = objReader(6)
objDetails.HomePage = objReader(7)
objDetails.PostCode = objReader(8)
objDetails.Address1 = objReader(9)
objDetails.Address2 = objReader(10)
objDetails.Address3 = objReader(11)
objDetails.Town = objReader(12)
objDetails.County = objReader(13)
objDetails.Country = objReader(14)
'objDetails.ClientID = objReader.GetString(15)
'objDetails.ManagerID = objReader.GetString(16)
'objDetails.CreatorID = objReader.GetString(17)
end while
objReader.Close

return objDetails
End function

End Class

Public Class PublicForum
Private objConn as new OleDbConnection (System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))


Public function DisplayForum(developmentID) As OleDbDataReader

Dim objCmd As New OleDbCommand("spDisplayPFTopics", objConn)
objCmd.CommandType = CommandType.StoredProcedure

Dim objParam As New OleDbParameter("@dotnet.itags.org.DevelopmentID", OleDbType.Char)
objParam.Value = developmentID
objCmd.Parameters.Add(objParam)
Dim objReader as OleDbDataReader

try
'objCmd.Connection.Open()
objConn.Open()
return objCmd.ExecuteReader
catch ex as OleDbException
throw ex
end try
End Function

Public function DisplayThreads(topicID) As OleDbDataReader
Dim objCmd As New OleDbCommand("spDisplayPFThreads", objConn)
objCmd.CommandType = CommandType.StoredProcedure

Dim objParam As New OleDbParameter("@dotnet.itags.org.TopicID", OleDbType.Char)
objParam.Value = topicID
objCmd.Parameters.Add(objParam)
Dim objReader as OleDbDataReader

try
objConn.Open()
return objCmd.ExecuteReader
catch ex as OleDbException
throw ex
end try
End Function

Public function DisplayMessages(threadID) As OleDbDataReader
Dim objCmd As New OleDbCommand("spDisplayPFEntries", objConn)
objCmd.CommandType = CommandType.StoredProcedure

Dim objParam As New OleDbParameter("@dotnet.itags.org.ThreadID", OleDbType.Char)
objParam.Value = threadID
objCmd.Parameters.Add(objParam)
Dim objReader as OleDbDataReader

try
objConn.Open()
return objCmd.ExecuteReader
catch ex as OleDbException
throw ex
end try
End Function

Sub ReplyToForum (threadID, creatorID, entry)
Dim objCmd As New OleDbCommand("spAddPFEntry", objConn)
objCmd.CommandType = CommandType.StoredProcedure

Dim objParam As New OleDbParameter("@dotnet.itags.org.ThreadID", OleDbType.Char)
objParam.Value = threadID
objCmd.Parameters.Add(objParam)

objParam = New OleDbParameter("@dotnet.itags.org.CreatorID", OleDbType.Char)
objParam.Value = creatorID
objCmd.Parameters.Add(objParam)

objParam = New OleDbParameter("@dotnet.itags.org.Entry", OleDbType.Char)
objParam.Value = entry
objCmd.Parameters.Add(objParam)

try
objConn.Open()
objCmd.ExecuteNonQuery
objConn.Close()
catch ex as OleDbException
throw ex
end try
End Sub


End Class
End Namespace

Any hints greatly received!

Thank you for your time

Shaun

Wow.. I don't think the problem lies within the code that you have bolded but within all the functions that return DataReader objects. You're going to have to pass them as:
return objDataReader(CommandBehavior.CloseConnection)
and then in your main code that is actually calling the function and expecting a reader in return you must do:
dim dr as SqlDataReader
dr = Class.MethodReturnsDatareader
dr.close()
Also, you may want to add Finally blocks to all those Try blocks and explicitly close the connection there. Because if any of those methods error out, the connection is still open...

Thanks Optik.

I will try what you suggest. I'm a bit confused though, as I've simply adapted examples out of my Teach Yourself ASP.Net in 21 Days Book. Would you be able to shed a little light on why I need to use objDataReader(CommandBehavior.CloseConnection)? What was it that I was doing wrong?
Many thanks
Shaun


Hi Optik

I would just like to say that this did infact solve the problem. So this issue is now resolved.

It would be good if I could just understand why!?!

Many thanks for your time

Shaun


Quoted from MSDN
"While theSqlDataReader is in use, the associatedSqlConnection is busy serving theSqlDataReader. While in this state, no other operations can be performed on theSqlConnection other than closing it. This is the case until you call theSqlDataReader.Close method. If theSqlDataReader is created withCommandBehavior set toCloseConnection, closing theSqlDataReader closes the connection automatically."


Cheers me dears!

The connection was closed.

Hi, I have a web page that call another one with this code:

WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);

The web page called read the parameters, run the code and return 1 or
0.

The code that prepare the answer is the follow:

private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}

When I run the code happen an error:

Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.

How can I solve the problem?

Thanks in advice.Try commenting out Response.Close(); and see what happens.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
<support@dotnet.itags.org.missmobile.netwrote in message
news:1180699146.296715.194340@dotnet.itags.org.o5g2000hsb.googlegro ups.com...

Quote:

Originally Posted by

Hi, I have a web page that call another one with this code:
>
WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);
>
The web page called read the parameters, run the code and return 1 or
0.
>
The code that prepare the answer is the follow:
>
private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}
>
When I run the code happen an error:
>
Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
>
Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.
>
>
How can I solve the problem?
>
Thanks in advice.
>


On 2 Giu, 00:56, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@dotnet.itags.org.comcast.netNoSpamMwrote:

Quote:

Originally Posted by

Try commenting out Response.Close(); and see what happens.
>
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
>
************************************************
Think outside the box!
************************************************<supp...@dotnet.itags.org.missmobile.netwrote in message
>
news:1180699146.296715.194340@dotnet.itags.org.o5g2000hsb.googlegro ups.com...
>
>
>

Quote:

Originally Posted by

Hi, I have a web page that call another one with this code:


>

Quote:

Originally Posted by

WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);


>

Quote:

Originally Posted by

The web page called read the parameters, run the code and return 1 or
0.


>

Quote:

Originally Posted by

The code that prepare the answer is the follow:


>

Quote:

Originally Posted by

private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}


>

Quote:

Originally Posted by

When I run the code happen an error:


>

Quote:

Originally Posted by

Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.


>

Quote:

Originally Posted by

Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.


>

Quote:

Originally Posted by

How can I solve the problem?


>

Quote:

Originally Posted by

Thanks in advice.- Nascondi testo tra virgolette -


>
- Mostra testo tra virgolette -


Hi, if I comment Response.Close(); works fine but i receive too HTML
code.

The page must contain only the value of "StrResult" because the same
page are request by a lot of VB6 application.

I can't upgrade all VB6 application...

Thanks in advice

Matteo

the connection string property has not been initialized

in one of my classes i have a private function, which sets connection
other public shared functions call this connection
when i try to call the public shared functions say to my form code i get that error
any one ever had that beforemake sure that the SQLCommand object's connection property is set to the SQLConnection object:

string connString = "blah"; //insert REAL conn string here
SQLConnection theConnection = new SQLConnection(connString);
SQLCommand theSQLCommand = new SQLCommand();
theSQLCommand.Connection = theConnection; //This line
..
..

The connections current state is Connecting.

Only on one page that I got in my project do I get this error:

ExecuteReader requires an open and available Connection. The connection's current state is Connecting.

Shouldn't the connection object automatically wait until it's open and then move on ?

The code:


Dim SQL As String, MyRead As OleDb.OleDbDataReader

Try
MyConn = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
If MyConn.State <> ConnectionState.Open Then
MyConn.Open()
End If
Try
SQL = "SELECT * FROM tbl_table"
Dim MyCMD As New OleDb.OleDbCommand(SQL, MyConn)
MyRead = MyCMD.ExecuteReader
MyCMD.Dispose()
If Not MyRead.Read = False Then
LN = MyRead.GetString(0)
FN = MyRead.GetString(1)
EML = MyRead.GetString(2)
PHN = MyRead.GetString(3)
ADD = MyRead.GetString(4)
CITY = MyRead.GetString(5)
STATE = MyRead.GetString(6)
ZIP = MyRead.GetString(7)
COUNTRY = MyRead.GetString(8)
FAX = MyRead.GetString(9)
CELL = MyRead.GetString(10)
URL = MyRead.GetString(11)
COMPANY = MyRead.GetString(12)
End If
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyRead.Close()
End Try
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyConn.Dispose()
End Try

Have you stepped through the code to find out if it's executing the myConn.Open method?
Not yet, the thing is that I can just refresh the page and it will start loading normally, it will do this completely at random.

The connection was not closed. The connections current state is open

I'm not sure why I am still getting this connection error

www.photopizzaz.biz/allcode.txt

resolved it, please disregard this thread.


Okay, But you might want to remove that code for security reasons(from the server).

The connection was closed.

Hi, I have a web page that call another one with this code:
WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);
The web page called read the parameters, run the code and return 1 or
0.
The code that prepare the answer is the follow:
private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}
When I run the code happen an error:
Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.
How can I solve the problem?
Thanks in advice.Try commenting out Response.Close(); and see what happens.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
****************************************
********
Think outside the box!
****************************************
********
<support@dotnet.itags.org.missmobile.net> wrote in message
news:1180699146.296715.194340@dotnet.itags.org.o5g2000hsb.googlegroups.com...
> Hi, I have a web page that call another one with this code:
> WebClient SendSite = new WebClient();
> SendSite.Headers.Add("Content-Type", "application/x-www-form-
> urlencoded");
> string StrReqSend = "Par1=aaa&Par2=2222";
> byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
> byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
> prova.aspx", "POST", Param);
> The web page called read the parameters, run the code and return 1 or
> 0.
> The code that prepare the answer is the follow:
> private void WriteResult(string StrResult)
> {
> Response.ClearHeaders();
> Response.ClearContent();
> Response.ContentType = "text/plain";
> Response.ContentEncoding = System.Text.Encoding.Default;
> Response.Write(StrResult);
> Response.Flush();
> Response.Close();
> }
> When I run the code happen an error:
> Unable to read data from the transport connection: The connection was
> closed.
> Description: An unhandled exception occurred during the execution of
> the current web request. Please review the stack trace for more
> information about the error and where it originated in the code.
> Exception Details: System.IO.IOException: Unable to read data from the
> transport connection: The connection was closed.
>
> How can I solve the problem?
> Thanks in advice.
>
On 2 Giu, 00:56, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@dotnet.itags.org.comcast.netNoSpamM> wrote:
> Try commenting out Response.Close(); and see what happens.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
> Co-author: Microsoft Expression Web Bible (upcoming)
> ****************************************
********
> Think outside the box!
> ****************************************
********<supp...@dotnet.itags.org.missmobile.net> w
rote in message
> news:1180699146.296715.194340@dotnet.itags.org.o5g2000hsb.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>
> - Mostra testo tra virgolette -
Hi, if I comment Response.Close(); works fine but i receive too HTML
code.
The page must contain only the value of "StrResult" because the same
page are request by a lot of VB6 application.
I can't upgrade all VB6 application...
Thanks in advice
Matteo

The ConnectionString property has not been initialized.

I am trying to use a connection string from web.config file for the first time. Here is my code.

Try
Dim cmd As String = _
("SELECT [Name], BirthDate, StartDate From " & _
"Employees WHERE PayGroup='20' AND Status='A'")

Dim conn As String = _
System.Configuration. _
ConfigurationManager. _
AppSettings("myConString")

Dim myConn As New SqlConnection(conn)
Dim myCmd As New SqlDataAdapter(cmd, myConn)
Dim ds As New DataSet
myCmd.Fill(ds)
gvEmp.DataSource = ds
gvEmp.DataBind()

Catch ex As Exception
Response.Write(ex.Message & "<br>")
Finally

End Try

I am getting The ConnectionString property has not been initialized. What am I doing wrong?Show your web.config code.
<connectionStrings>
<add name="myConString" connectionString="Data Source=myServer;Initial Catalog=Employees;User ID=myUser;Password=mypass"
providerName="System.Data.SqlClient" />
</connectionStrings>

Thursday, March 22, 2012

The eternal connection string problem

I am still struggling with a connection string problem.

I have tried a lot of different, and non-working, solutions.

I am developing on a laptop. When I get this the way I want it, I will upload it to my web site. Naturally the physical address is different for the DB file. I am trying to find a solution where I don't have to cut and paste.

I have tried web.config and it works okay for the laptop, but when I upload it and edit the .config to the new address on the server it doesn't work. I just tried the below and it doesn't work either.


Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\AITCdotnet\atad\AlpaIntlTC_BP.mdb;

Doesn't "c:\inetpub\wwwroot" take you to a site root? Shouldn't this point to my site root folder on the server, even if it's on a "D" drive?

Regards,
Is your mdb file stored under your application folder? You may need to use Server.MapPath() method to get the full path to your database at runtime. Instead of storing the full path in web.config, just store the relative path. Get this working on your own machine first.

Jamie,
Thanks for the reply. I have tried variously; Server.MapPath, Path.GetFullPath, and Application.Path to try and "get" the physical path I need. I had no luck using any of those methods in the web.config. I concluded that was due to the fact that is a only an XML/text string file and it wouldn't be "complied" or processed when the .dll read its contents.

The last part of the filename to the .mdb is indeed the same on both the server and the laptop, but its the first part of the address that I am just not getting.

I have assumed that if I run Server.MapPath, that it is related to the directory in which the aspx file that "asked" for it lives. Then anything it returns could be the first half and the known subfolder and filenames could be appended.

Given the connection string I originally posted, can you give me some idea how I should use the Server.MapPath method?

I have read lots of Forum posts, have a whole collection of MS Press and other books, and only seem to find over-simplified or incomplete examples. I can't be the only person on the planet who is trying to solve this problem.

Thanks again.
To answer your questions

www.siteroot.net
AITCdotnet - folder
atad - folder
AlpaIntlTC_BP.mdb
You should call Server.MapPath() from your page class, passing in the database name that is stored in your web.config file.
You have to use Server.MapPath, Application.Path, etc. in your code, not in web.config (I would suggest usingRequest.PhysicalApplicationPath as this will give you the path to your root folder, not to the .aspx file). For example:

 void Page_Load ( Object src, EventArgs eArgs ) {

String ConnPath = Request.PhysicalApplicationPath + ConfigurationSettings.AppSettings ( "ConnPath" );

...
}


I have been working with this approach for 30 hours. I have modifiied it using Server.MapPath since this recent exchange.


Private Sub cnSb()
Dim sbPath As New StringBuilder(200)
sbPath.Append("""")
sbPath.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=")
sbPath.Append(Server.MapPath("\AITCdotnet\atad\AlpaIntlTC_BP.mdb"))
sbPath.Append(";""")
'Response.Write(sbPath.ToString)
Dim cnStr As String = sbPath.ToString
Dim cnIssues As New OleDb.OleDbConnection(cnStr)
End Sub

If you uncomment the Response.Write and comment out the two following Dim's, the sbPath returns a perfectly formatted connection string.

However, whether I use the code as shown, or strike the first Dim and pass sbPath.ToString to the Connection object, I get an error about the "initialization string not being properly formatted at index 142." Near as I can tell, that is around the end of the string, but I can;t determine what it thinks is wrong. It has a trailing semi-colon, so any extra "spaces" shouldn't matter.

Once I can get this to work in the code, I will try and place the known end of the relative path in the web.config file. I think I can make that work, but first I have to get the conn string to work at all.

? Thoughts

PS. If it isn't already horribly obvious, I am still looking mostly upwards on the learning curve.
Link to a previous post along the same effort to make this connection string work. Previous work was with ASP/VBScript using DSN's...that was painless comnpared to this.
I changed Server.MapPath to Request.PhysicalApplicationPath and modified the rest of that line to satisfy the syntax. It returns the same otherwise perfect conn string in the Response Write, but fails the same way with index 142.
The connection string itself doesn't contain quotation marks!! Use:

 Private Sub cnSb()

Dim sbPath As New StringBuilder(200)
sbPath.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=")
sbPath.Append(Server.MapPath("\AITCdotnet\atad\AlpaIntlTC_BP.mdb"))
sbPath.Append(";")
Dim cnStr As String = sbPath.ToString
Dim cnIssues As New OleDb.OleDbConnection(cnStr)
End Sub


The reason that I said to user Request.PhysicalApplicationPath is so that if you use this code in files that are in subdirectories, etc then you don't have to change the path that you pass into Server.MapPath().
> then you don't have to change the path that you pass into Server.MapPath().

Should read:

then you don't have to change the path that you would have to pass into Server.MapPath().
Some success! I have it working now on my laptop. I had to edit the initialization string in the "web designer Region" in order for the index 142 problem to go away. I think the Properties box, the web designer region and the "real" code must have it out before any application will work. With your help I stumbled into a workable balance.

Regretably it is still gving an error on the web server. I'll have to investigate that a bit more, since it may be a problem of the /bin folder.

Thanks to my New Brunswick and Yorkshire friends for your kind help this morning.
The error I am now getting on the web server :

Server Error in '/' Application.
------------------------

File or assembly name System.Data, or one of its dependencies, was not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: File or assembly name System.Data, or one of its dependencies, was not found.

This leads me to believe that the Request.PhysicalApplicationPath object may be from a namespace other than those I "Imported." Can you tell me where it derives from?
I have now imported System.Web, having answered my own question by pursuing a link to the MSDN library online provided by Steven. It did nothing to fix the above error message, and did not harm the successful running of the application on the "laptop/localhost."

Any thoughts?