Showing posts with label developing. Show all posts
Showing posts with label developing. Show all posts

Wednesday, March 28, 2012

Trouble Connecting

I'm developing locally on my computer
Installed on My computer:
OS - XP Professional
IIS
1.1.Net Framework
MSDE
WebMatrix
Macromedia DreamWeaver MX



Having a Problem Connecting to my SQL Database using the following:

void Button_Click(object sender, EventArgs e)
{
SqlConnection conNewstore;
string strInsert;
SqlCommand cmdInsert;

conNewstore = new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Newstore" );
strInsert = "Insert OrderPayment ( FullName, OrderID, CustomerID ) Values (@dotnet.itags.org.FullName, @dotnet.itags.org.OrderID, @dotnet.itags.org.CustomerID )";
cmdInsert = new SqlCommand( strInsert, conNewstore );
cmdInsert.Parameters.Add( "@dotnet.itags.org.FullName", FullName.Text );
cmdInsert.Parameters.Add( "@dotnet.itags.org.OrderID", OrderID.Text );
cmdInsert.Parameters.Add( "@dotnet.itags.org.CustomerID", CustomerID.Text );
conNewstore.Open();
cmdInsert.ExecuteNonQuery();
conNewstore.Close();
}



Please Note: if I change the connection string to this
conNewstore = new SqlConnection( "Server=(local);USER ID=sa;Password=Mypassword;database=Newstore" );
It works fine.

But if I use this connection:conNewstore = new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Newstore" ); It does not work

Any Help would be Great!! Thank You!





Here is the error message I receive

Server Error in '/NewStoreCS' Application.

Login failed for user 'MYNAME\ASPNET'.
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.Data.SqlClient.SqlException: Login failed for user 'MYNAME\ASPNET'.

Source Error:

Line 14: cmdInsert = new SqlCommand( strInsert, conNewstore );
Line 15: cmdInsert.Parameters.Add( "@dotnet.itags.org.FullName", txtFullName.Text );
Line 16: conNewstore.Open();
Line 17: cmdInsert.ExecuteNonQuery();
Line 18: conNewstore.Close();

Source File: C:\Inetpub\wwwroot\NewStoreCS\InsertPage.aspx Line: 16

Stack Trace:

[SqlException: Login failed for user 'MYNAME\ASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.InsertPage_aspx.Button_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\NewSToreCS\InsertPage.aspx:16
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573


Since you are using "Integrated Security=SSPI", the login credentials for the ASPNET user are used to log into the SQL Server. If you want to use this integrated security you need to create a MYNAME\ASPNET account in SQL Server and give it the proper permissions.
Thank you.

Do you know where I can read (find info) on how to do this? Thanks again.

Trouble developing on remote web server.

Running VS.NET 2003 on WinXP pro. Created ASP.NET Web App on remote Win2003
Server. Installed remote debugging tools on server. When I try to run the
app, I get the following error.
"Error while trying to run project: unable to start debugging on the web
server. Not enough storage is available to complete this operation."
I've checked disk space both on the development box and the server. Plenty
(gigs) of space available. Is there anything else that could be causing this
error?
Thanks.I am experiencing the same problem. Did you find a solution? Does anyone
else have information on this issue?
Thanks,
Nathan
"Terry Olsen" wrote:

> Running VS.NET 2003 on WinXP pro. Created ASP.NET Web App on remote Win200
3
> Server. Installed remote debugging tools on server. When I try to run th
e
> app, I get the following error.
> "Error while trying to run project: unable to start debugging on the web
> server. Not enough storage is available to complete this operation."
> I've checked disk space both on the development box and the server. Plent
y
> (gigs) of space available. Is there anything else that could be causing th
is
> error?
> Thanks.
>
>

Monday, March 26, 2012

Trouble developing on remote web server.

Running VS.NET 2003 on WinXP pro. Created ASP.NET Web App on remote Win2003
Server. Installed remote debugging tools on server. When I try to run the
app, I get the following error.

"Error while trying to run project: unable to start debugging on the web
server. Not enough storage is available to complete this operation."

I've checked disk space both on the development box and the server. Plenty
(gigs) of space available. Is there anything else that could be causing this
error?

Thanks.I am experiencing the same problem. Did you find a solution? Does anyone
else have information on this issue?

Thanks,

Nathan

"Terry Olsen" wrote:

> Running VS.NET 2003 on WinXP pro. Created ASP.NET Web App on remote Win2003
> Server. Installed remote debugging tools on server. When I try to run the
> app, I get the following error.
> "Error while trying to run project: unable to start debugging on the web
> server. Not enough storage is available to complete this operation."
> I've checked disk space both on the development box and the server. Plenty
> (gigs) of space available. Is there anything else that could be causing this
> error?
> Thanks.
>

Trouble getting the ASP.NET error page to appear remotely

I have been developing a web application on a local host and then
using 'Copy Project' to copy all the files up to the ISP location.
When I run the application locally then all is OK. When I run the
application from the ISP site I get an runtime error.
Because the default page does not givem me any indication as to what
the actual problem is, then I change the web.config file using the
recommended custom error tags as follows:
<customErrors mode= "Off" />
This did not result in me getting the detailed page that would have
been displayed at the server on the ISP. So I tried to create a custom
page by creating a HTML file 'mycustompage.htm' and the modifying the
tag to give:
<customErrors mode= "RemoteOnly" defaultRedirect="mycustompage.htm" />
But the result is still the default page with no indication of error.
It is as if the application is not reading the web.config file.
The tag above had been entered inside the existing <system.web> tag.
Any help would be appreciated.
John L"John Lundrigan" <jonel@.glenavon1.demon.co.uk> wrote in message
news:gkqac05vk2ctuc2bchs18iru81muov4q21@.
4ax.com...
> I have been developing a web application on a local host and then
> using 'Copy Project' to copy all the files up to the ISP location.
> When I run the application locally then all is OK. When I run the
> application from the ISP site I get an runtime error.
...

> But the result is still the default page with no indication of error.
> It is as if the application is not reading the web.config file.
Maybe it isn't reading it. Try introducing a syntax error into the
web.config file and see if the syntax error is caught.
Are you sure your ISP has your app set up as an application in IIS?
--
John Saunders
johnwsaundersiii at hotmail

Trouble getting the ASP.NET error page to appear remotely

I have been developing a web application on a local host and then
using 'Copy Project' to copy all the files up to the ISP location.
When I run the application locally then all is OK. When I run the
application from the ISP site I get an runtime error.

Because the default page does not givem me any indication as to what
the actual problem is, then I change the web.config file using the
recommended custom error tags as follows:

<customErrors mode= "Off" /
This did not result in me getting the detailed page that would have
been displayed at the server on the ISP. So I tried to create a custom
page by creating a HTML file 'mycustompage.htm' and the modifying the
tag to give:

<customErrors mode= "RemoteOnly" defaultRedirect="mycustompage.htm" /
But the result is still the default page with no indication of error.
It is as if the application is not reading the web.config file.

The tag above had been entered inside the existing <system.web> tag.

Any help would be appreciated.

John L"John Lundrigan" <jonel@.glenavon1.demon.co.uk> wrote in message
news:gkqac05vk2ctuc2bchs18iru81muov4q21@.4ax.com...
> I have been developing a web application on a local host and then
> using 'Copy Project' to copy all the files up to the ISP location.
> When I run the application locally then all is OK. When I run the
> application from the ISP site I get an runtime error.
...

> But the result is still the default page with no indication of error.
> It is as if the application is not reading the web.config file.

Maybe it isn't reading it. Try introducing a syntax error into the
web.config file and see if the syntax error is caught.

Are you sure your ISP has your app set up as an application in IIS?
--
John Saunders
johnwsaundersiii at hotmail

Trouble opening a connection to SQL 2000 DB

I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
connect to the DB from within my code. I've created a .vb class that
houses a private Connection() that other functions within the class can
call to connect to the database. In the calling function, I've declared
my connection object and called the "Open" method on the object.
However, when I attempt to execute the stored procedure command by
calling the "ExecuteScalar" method, I get the following error:
"ExecuteScalar requires an open and available Connection. The
connection's current state is closed."
Here's the code from my class:
Imports System.Data
Imports System.Data.SqlClient
Namespace Encompass
Public Class EncompassSecurity
Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
Dim strHRID As String
'Create command object
Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
cmd.CommandType = CommandType.StoredProcedure
'Open DB connection
Dim DBConnection As SqlConnection = Connection()
DBConnection.Open()
'Input parameters
Dim inNTUserParam As New SqlParameter("@dotnet.itags.org.NT_UserID", SqlDbType.VarChar)
inNTUserParam.Direction = ParameterDirection.Input
inNTUserParam.Value = strNTUserID
cmd.Parameters.Add(inNTUserParam)
'Output parameters
Dim outHRIDParam As New SqlParameter("@dotnet.itags.org.HRID", SqlDbType.Int)
outHRIDParam.Direction = ParameterDirection.Output
cmd.Parameters.Add(outHRIDParam)
'Run stored procedure
strHRID = cmd.ExecuteScalar()
Return (strHRID)
'Close DB connection
DBConnection.Close()
End Function
Private Shared Function Connection() As SqlConnection
Dim strConnectionString As String
strConnectionString = ConfigurationManager.ConnectionStrings(
"Conn").ConnectionString
Return New SqlConnection(strConnectionString)
End Function
End Class
End
Namespace
Here's the code from my web.config file:
<?
xml version="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
-->
<
configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<
connectionStrings>
<
add name="Conn" connectionString="Data Source=ServerName;Initial
Catalog=NPASDV;uid=UserName;password=***
****;"
providerName="System.Data.SqlClient" />
</
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.
-->
<
roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
<
compilation debug="true" strict="false" explicit="true" />
<
pages>
<
namespaces>
<
clear />
<
add namespace="System" />
<
add namespace="System.Collections" />
<
add namespace="System.Collections.Specialized" />
<
add namespace="System.Configuration" />
<
add namespace="System.Text" />
<
add namespace="System.Text.RegularExpressions" />
<
add namespace="System.Web" />
<
add namespace="System.Web.Caching" />
<
add namespace="System.Web.SessionState" />
<
add namespace="System.Web.Security" />
<
add namespace="System.Web.Profile" />
<
add namespace="System.Web.UI" />
<
add namespace="System.Web.UI.WebControls" />
<
add namespace="System.Web.UI.WebControls.WebParts" />
<
add namespace="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.
-->
<
authentication mode="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>
What am I doing wrong? Any help would be most appreciated!!
Manuel Garr, MCPYou have created a Commad object with a connection object which is not open
yet.
Dim DBConnection As SqlConnection = Connection()
DBConnection.Open()
Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
cmd.CommandType = CommandType.StoredProcedure
"mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> connect to the DB from within my code. I've created a .vb class that
> houses a private Connection() that other functions within the class can
> call to connect to the database. In the calling function, I've declared
> my connection object and called the "Open" method on the object.
> However, when I attempt to execute the stored procedure command by
> calling the "ExecuteScalar" method, I get the following error:
> "ExecuteScalar requires an open and available Connection. The
> connection's current state is closed."
>
> Here's the code from my class:
>
> Imports System.Data
> Imports System.Data.SqlClient
>
> Namespace Encompass
>
> Public Class EncompassSecurity
>
> Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
>
> Dim strHRID As String
>
> 'Create command object
>
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> cmd.CommandType = CommandType.StoredProcedure
>
> 'Open DB connection
>
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
>
> 'Input parameters
>
> Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> inNTUserParam.Direction = ParameterDirection.Input
>
> inNTUserParam.Value = strNTUserID
>
> cmd.Parameters.Add(inNTUserParam)
>
> 'Output parameters
>
> Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> outHRIDParam.Direction = ParameterDirection.Output
>
> cmd.Parameters.Add(outHRIDParam)
>
> 'Run stored procedure
> strHRID = cmd.ExecuteScalar()
>
> Return (strHRID)
>
> 'Close DB connection
> DBConnection.Close()
>
> End Function
>
> Private Shared Function Connection() As SqlConnection
>
> Dim strConnectionString As String
> strConnectionString = ConfigurationManager.ConnectionStrings(
>
> "Conn").ConnectionString
>
> Return New SqlConnection(strConnectionString)
>
> End Function
>
> End Class
> End
>
> Namespace
> Here's the code from my web.config file:
>
> <?
>
> xml version="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
>
> -->
>
> <
>
> configuration
> xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <
>
> connectionStrings>
> <
>
> add name="Conn" connectionString="Data Source=ServerName;Initial
> Catalog=NPASDV;uid=UserName;password=***
****;"
>
> providerName="System.Data.SqlClient" />
> </
>
> 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.
>
> -->
> <
>
> roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> <
>
> compilation debug="true" strict="false" explicit="true" />
> <
>
> pages>
> <
>
> namespaces>
> <
>
> clear />
> <
>
> add namespace="System" />
> <
>
> add namespace="System.Collections" />
> <
>
> add namespace="System.Collections.Specialized" />
> <
>
> add namespace="System.Configuration" />
> <
>
> add namespace="System.Text" />
> <
>
> add namespace="System.Text.RegularExpressions" />
> <
>
> add namespace="System.Web" />
> <
>
> add namespace="System.Web.Caching" />
> <
>
> add namespace="System.Web.SessionState" />
> <
>
> add namespace="System.Web.Security" />
> <
>
> add namespace="System.Web.Profile" />
> <
>
> add namespace="System.Web.UI" />
> <
>
> add namespace="System.Web.UI.WebControls" />
> <
>
> add namespace="System.Web.UI.WebControls.WebParts" />
> <
>
> add namespace="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.
>
> -->
> <
>
> authentication mode="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>
> What am I doing wrong? Any help would be most appreciated!!
>
> --
> Manuel Garr, MCP
>
Winista wrote:
> You have created a Commad object with a connection object which is not ope
n
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure
>
A command object can be created without the connection being opened.
However, your code is partially correct. The only thing that needs to
be changed is the call to DBConnection.Open() should be made right
before the cmd.ExecuteScalar() call.
> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
--
Manuel
"Winista" wrote:
> You have created a Commad object with a connection object which is not ope
n
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure
> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
Thanks for you help too!
--
Manuel
"tdavisjr" wrote:
> Winista wrote:
>
> A command object can be created without the connection being opened.
> However, your code is partially correct. The only thing that needs to
> be changed is the call to DBConnection.Open() should be made right
> before the cmd.ExecuteScalar() call.
>
>
>
Thanks so much for your help. It's working now.
--
Manuel
"Winista" wrote:
> You have created a Commad object with a connection object which is not ope
n
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure
> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...

Trouble opening a connection to SQL 2000 DB

I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
connect to the DB from within my code. I've created a .vb class that
houses a private Connection() that other functions within the class can
call to connect to the database. In the calling function, I've declared
my connection object and called the "Open" method on the object.
However, when I attempt to execute the stored procedure command by
calling the "ExecuteScalar" method, I get the following error:

"ExecuteScalar requires an open and available Connection. The
connection's current state is closed."

Here's the code from my class:

Imports System.Data
Imports System.Data.SqlClient

Namespace Encompass

Public Class EncompassSecurity

Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String

Dim strHRID As String

'Create command object

Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
cmd.CommandType = CommandType.StoredProcedure

'Open DB connection

Dim DBConnection As SqlConnection = Connection()
DBConnection.Open()

'Input parameters

Dim inNTUserParam As New SqlParameter("@dotnet.itags.org.NT_UserID", SqlDbType.VarChar)
inNTUserParam.Direction = ParameterDirection.Input

inNTUserParam.Value = strNTUserID

cmd.Parameters.Add(inNTUserParam)

'Output parameters

Dim outHRIDParam As New SqlParameter("@dotnet.itags.org.HRID", SqlDbType.Int)
outHRIDParam.Direction = ParameterDirection.Output

cmd.Parameters.Add(outHRIDParam)

'Run stored procedure
strHRID = cmd.ExecuteScalar()

Return (strHRID)

'Close DB connection
DBConnection.Close()

End Function

Private Shared Function Connection() As SqlConnection

Dim strConnectionString As String
strConnectionString = ConfigurationManager.ConnectionStrings(

"Conn").ConnectionString

Return New SqlConnection(strConnectionString)

End Function

End Class
End

Namespace
Here's the code from my web.config file:

<?

xml version="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

--
<

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

connectionStrings>
<

add name="Conn" connectionString="Data Source=ServerName;Initial
Catalog=NPASDV;uid=UserName;password=*******;"

providerName="System.Data.SqlClient" />
</

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.

-->
<

roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
<

compilation debug="true" strict="false" explicit="true" />
<

pages>
<

namespaces>
<

clear />
<

add namespace="System" />
<

add namespace="System.Collections" />
<

add namespace="System.Collections.Specialized" />
<

add namespace="System.Configuration" />
<

add namespace="System.Text" />
<

add namespace="System.Text.RegularExpressions" />
<

add namespace="System.Web" />
<

add namespace="System.Web.Caching" />
<

add namespace="System.Web.SessionState" />
<

add namespace="System.Web.Security" />
<

add namespace="System.Web.Profile" />
<

add namespace="System.Web.UI" />
<

add namespace="System.Web.UI.WebControls" />
<

add namespace="System.Web.UI.WebControls.WebParts" />
<

add namespace="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.

-->
<

authentication mode="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>
What am I doing wrong? Any help would be most appreciated!!

--
Manuel Garr, MCPYou have created a Commad object with a connection object which is not open
yet.

Dim DBConnection As SqlConnection = Connection()
DBConnection.Open()

Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
cmd.CommandType = CommandType.StoredProcedure

"mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> connect to the DB from within my code. I've created a .vb class that
> houses a private Connection() that other functions within the class can
> call to connect to the database. In the calling function, I've declared
> my connection object and called the "Open" method on the object.
> However, when I attempt to execute the stored procedure command by
> calling the "ExecuteScalar" method, I get the following error:
> "ExecuteScalar requires an open and available Connection. The
> connection's current state is closed."
>
> Here's the code from my class:
>
> Imports System.Data
> Imports System.Data.SqlClient
>
> Namespace Encompass
>
> Public Class EncompassSecurity
>
> Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
>
> Dim strHRID As String
>
> 'Create command object
>
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> cmd.CommandType = CommandType.StoredProcedure
>
> 'Open DB connection
>
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
>
> 'Input parameters
>
> Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> inNTUserParam.Direction = ParameterDirection.Input
>
> inNTUserParam.Value = strNTUserID
>
> cmd.Parameters.Add(inNTUserParam)
>
> 'Output parameters
>
> Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> outHRIDParam.Direction = ParameterDirection.Output
>
> cmd.Parameters.Add(outHRIDParam)
>
> 'Run stored procedure
> strHRID = cmd.ExecuteScalar()
>
> Return (strHRID)
>
> 'Close DB connection
> DBConnection.Close()
>
> End Function
>
> Private Shared Function Connection() As SqlConnection
>
> Dim strConnectionString As String
> strConnectionString = ConfigurationManager.ConnectionStrings(
>
> "Conn").ConnectionString
>
> Return New SqlConnection(strConnectionString)
>
> End Function
>
> End Class
> End
>
> Namespace
> Here's the code from my web.config file:
>
> <?
>
> xml version="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
>
> -->
>
> <
>
> configuration
> xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <
>
> connectionStrings>
> <
>
> add name="Conn" connectionString="Data Source=ServerName;Initial
> Catalog=NPASDV;uid=UserName;password=*******;"
>
> providerName="System.Data.SqlClient" />
> </
>
> 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.
>
> -->
> <
>
> roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> <
>
> compilation debug="true" strict="false" explicit="true" />
> <
>
> pages>
> <
>
> namespaces>
> <
>
> clear />
> <
>
> add namespace="System" />
> <
>
> add namespace="System.Collections" />
> <
>
> add namespace="System.Collections.Specialized" />
> <
>
> add namespace="System.Configuration" />
> <
>
> add namespace="System.Text" />
> <
>
> add namespace="System.Text.RegularExpressions" />
> <
>
> add namespace="System.Web" />
> <
>
> add namespace="System.Web.Caching" />
> <
>
> add namespace="System.Web.SessionState" />
> <
>
> add namespace="System.Web.Security" />
> <
>
> add namespace="System.Web.Profile" />
> <
>
> add namespace="System.Web.UI" />
> <
>
> add namespace="System.Web.UI.WebControls" />
> <
>
> add namespace="System.Web.UI.WebControls.WebParts" />
> <
>
> add namespace="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.
>
> -->
> <
>
> authentication mode="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>
> What am I doing wrong? Any help would be most appreciated!!
>
> --
> Manuel Garr, MCP
Winista wrote:
> You have created a Commad object with a connection object which is not open
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure

A command object can be created without the connection being opened.
However, your code is partially correct. The only thing that needs to
be changed is the call to DBConnection.Open() should be made right
before the cmd.ExecuteScalar() call.

> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> > I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> > connect to the DB from within my code. I've created a .vb class that
> > houses a private Connection() that other functions within the class can
> > call to connect to the database. In the calling function, I've declared
> > my connection object and called the "Open" method on the object.
> > However, when I attempt to execute the stored procedure command by
> > calling the "ExecuteScalar" method, I get the following error:
> > "ExecuteScalar requires an open and available Connection. The
> > connection's current state is closed."
> > Here's the code from my class:
> > Imports System.Data
> > Imports System.Data.SqlClient
> > Namespace Encompass
> > Public Class EncompassSecurity
> > Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
> > Dim strHRID As String
> > 'Create command object
> > Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> > cmd.CommandType = CommandType.StoredProcedure
> > 'Open DB connection
> > Dim DBConnection As SqlConnection = Connection()
> > DBConnection.Open()
> > 'Input parameters
> > Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> > inNTUserParam.Direction = ParameterDirection.Input
> > inNTUserParam.Value = strNTUserID
> > cmd.Parameters.Add(inNTUserParam)
> > 'Output parameters
> > Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> > outHRIDParam.Direction = ParameterDirection.Output
> > cmd.Parameters.Add(outHRIDParam)
> > 'Run stored procedure
> > strHRID = cmd.ExecuteScalar()
> > Return (strHRID)
> > 'Close DB connection
> > DBConnection.Close()
> > End Function
> > Private Shared Function Connection() As SqlConnection
> > Dim strConnectionString As String
> > strConnectionString = ConfigurationManager.ConnectionStrings(
> > "Conn").ConnectionString
> > Return New SqlConnection(strConnectionString)
> > End Function
> > End Class
> > End
> > Namespace
> > Here's the code from my web.config file:
> > <?
> > xml version="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
> > -->
> > <
> > configuration
> > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> > <
> > connectionStrings>
> > <
> > add name="Conn" connectionString="Data Source=ServerName;Initial
> > Catalog=NPASDV;uid=UserName;password=*******;"
> > providerName="System.Data.SqlClient" />
> > </
> > 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.
> > -->
> > <
> > roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> > <
> > compilation debug="true" strict="false" explicit="true" />
> > <
> > pages>
> > <
> > namespaces>
> > <
> > clear />
> > <
> > add namespace="System" />
> > <
> > add namespace="System.Collections" />
> > <
> > add namespace="System.Collections.Specialized" />
> > <
> > add namespace="System.Configuration" />
> > <
> > add namespace="System.Text" />
> > <
> > add namespace="System.Text.RegularExpressions" />
> > <
> > add namespace="System.Web" />
> > <
> > add namespace="System.Web.Caching" />
> > <
> > add namespace="System.Web.SessionState" />
> > <
> > add namespace="System.Web.Security" />
> > <
> > add namespace="System.Web.Profile" />
> > <
> > add namespace="System.Web.UI" />
> > <
> > add namespace="System.Web.UI.WebControls" />
> > <
> > add namespace="System.Web.UI.WebControls.WebParts" />
> > <
> > add namespace="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.
> > -->
> > <
> > authentication mode="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>
> > What am I doing wrong? Any help would be most appreciated!!
> > --
> > Manuel Garr, MCP
Thanks for you help too!
--
Manuel

"tdavisjr" wrote:

> Winista wrote:
> > You have created a Commad object with a connection object which is not open
> > yet.
> > Dim DBConnection As SqlConnection = Connection()
> > DBConnection.Open()
> > Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> > cmd.CommandType = CommandType.StoredProcedure
>
> A command object can be created without the connection being opened.
> However, your code is partially correct. The only thing that needs to
> be changed is the call to DBConnection.Open() should be made right
> before the cmd.ExecuteScalar() call.
>
>
> > "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> > news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> > > I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> > > connect to the DB from within my code. I've created a .vb class that
> > > houses a private Connection() that other functions within the class can
> > > call to connect to the database. In the calling function, I've declared
> > > my connection object and called the "Open" method on the object.
> > > However, when I attempt to execute the stored procedure command by
> > > calling the "ExecuteScalar" method, I get the following error:
> > > > "ExecuteScalar requires an open and available Connection. The
> > > connection's current state is closed."
> > > > > Here's the code from my class:
> > > > > Imports System.Data
> > > Imports System.Data.SqlClient
> > > > > Namespace Encompass
> > > > > Public Class EncompassSecurity
> > > > > Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
> > > > > Dim strHRID As String
> > > > > 'Create command object
> > > > > Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> > > cmd.CommandType = CommandType.StoredProcedure
> > > > > 'Open DB connection
> > > > > Dim DBConnection As SqlConnection = Connection()
> > > DBConnection.Open()
> > > > > 'Input parameters
> > > > > Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> > > inNTUserParam.Direction = ParameterDirection.Input
> > > > > inNTUserParam.Value = strNTUserID
> > > > > cmd.Parameters.Add(inNTUserParam)
> > > > > 'Output parameters
> > > > > Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> > > outHRIDParam.Direction = ParameterDirection.Output
> > > > > cmd.Parameters.Add(outHRIDParam)
> > > > > 'Run stored procedure
> > > strHRID = cmd.ExecuteScalar()
> > > > > Return (strHRID)
> > > > > 'Close DB connection
> > > DBConnection.Close()
> > > > > End Function
> > > > > Private Shared Function Connection() As SqlConnection
> > > > > Dim strConnectionString As String
> > > strConnectionString = ConfigurationManager.ConnectionStrings(
> > > > > "Conn").ConnectionString
> > > > > Return New SqlConnection(strConnectionString)
> > > > > End Function
> > > > > End Class
> > > End
> > > > > Namespace
> > > Here's the code from my web.config file:
> > > > > <?
> > > > > xml version="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
> > > > > -->
> > > > > <
> > > > > configuration
> > > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> > > <
> > > > > connectionStrings>
> > > <
> > > > > add name="Conn" connectionString="Data Source=ServerName;Initial
> > > Catalog=NPASDV;uid=UserName;password=*******;"
> > > > > providerName="System.Data.SqlClient" />
> > > </
> > > > > 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.
> > > > > -->
> > > <
> > > > > roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> > > <
> > > > > compilation debug="true" strict="false" explicit="true" />
> > > <
> > > > > pages>
> > > <
> > > > > namespaces>
> > > <
> > > > > clear />
> > > <
> > > > > add namespace="System" />
> > > <
> > > > > add namespace="System.Collections" />
> > > <
> > > > > add namespace="System.Collections.Specialized" />
> > > <
> > > > > add namespace="System.Configuration" />
> > > <
> > > > > add namespace="System.Text" />
> > > <
> > > > > add namespace="System.Text.RegularExpressions" />
> > > <
> > > > > add namespace="System.Web" />
> > > <
> > > > > add namespace="System.Web.Caching" />
> > > <
> > > > > add namespace="System.Web.SessionState" />
> > > <
> > > > > add namespace="System.Web.Security" />
> > > <
> > > > > add namespace="System.Web.Profile" />
> > > <
> > > > > add namespace="System.Web.UI" />
> > > <
> > > > > add namespace="System.Web.UI.WebControls" />
> > > <
> > > > > add namespace="System.Web.UI.WebControls.WebParts" />
> > > <
> > > > > add namespace="System.Web.UI.HtmlControls" />
> > > </
> > > > > namespaces>
> > > </
> > > > > pages>
> > > <!--
> >
--
Manuel

"Winista" wrote:

> You have created a Commad object with a connection object which is not open
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure
> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> > I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> > connect to the DB from within my code. I've created a .vb class that
> > houses a private Connection() that other functions within the class can
> > call to connect to the database. In the calling function, I've declared
> > my connection object and called the "Open" method on the object.
> > However, when I attempt to execute the stored procedure command by
> > calling the "ExecuteScalar" method, I get the following error:
> > "ExecuteScalar requires an open and available Connection. The
> > connection's current state is closed."
> > Here's the code from my class:
> > Imports System.Data
> > Imports System.Data.SqlClient
> > Namespace Encompass
> > Public Class EncompassSecurity
> > Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
> > Dim strHRID As String
> > 'Create command object
> > Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> > cmd.CommandType = CommandType.StoredProcedure
> > 'Open DB connection
> > Dim DBConnection As SqlConnection = Connection()
> > DBConnection.Open()
> > 'Input parameters
> > Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> > inNTUserParam.Direction = ParameterDirection.Input
> > inNTUserParam.Value = strNTUserID
> > cmd.Parameters.Add(inNTUserParam)
> > 'Output parameters
> > Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> > outHRIDParam.Direction = ParameterDirection.Output
> > cmd.Parameters.Add(outHRIDParam)
> > 'Run stored procedure
> > strHRID = cmd.ExecuteScalar()
> > Return (strHRID)
> > 'Close DB connection
> > DBConnection.Close()
> > End Function
> > Private Shared Function Connection() As SqlConnection
> > Dim strConnectionString As String
> > strConnectionString = ConfigurationManager.ConnectionStrings(
> > "Conn").ConnectionString
> > Return New SqlConnection(strConnectionString)
> > End Function
> > End Class
> > End
> > Namespace
> > Here's the code from my web.config file:
> > <?
> > xml version="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
> > -->
> > <
> > configuration
> > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> > <
> > connectionStrings>
> > <
> > add name="Conn" connectionString="Data Source=ServerName;Initial
> > Catalog=NPASDV;uid=UserName;password=*******;"
> > providerName="System.Data.SqlClient" />
> > </
> > 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.
> > -->
> > <
> > roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> > <
> > compilation debug="true" strict="false" explicit="true" />
> > <
> > pages>
> > <
> > namespaces>
> > <
> > clear />
> > <
> > add namespace="System" />
> > <
> > add namespace="System.Collections" />
> > <
> > add namespace="System.Collections.Specialized" />
> > <
> > add namespace="System.Configuration" />
> > <
> > add namespace="System.Text" />
> > <
> > add namespace="System.Text.RegularExpressions" />
> > <
> > add namespace="System.Web" />
> > <
> > add namespace="System.Web.Caching" />
> > <
> > add namespace="System.Web.SessionState" />
> > <
> > add namespace="System.Web.Security" />
> > <
> > add namespace="System.Web.Profile" />
> > <
> > add namespace="System.Web.UI" />
> > <
> > add namespace="System.Web.UI.WebControls" />
> > <
> > add namespace="System.Web.UI.WebControls.WebParts" />
> > <
> > add namespace="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.
> > -->
> > <
Thanks so much for your help. It's working now.
--
Manuel

"Winista" wrote:

> You have created a Commad object with a connection object which is not open
> yet.
> Dim DBConnection As SqlConnection = Connection()
> DBConnection.Open()
> Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", DBConnection)
> cmd.CommandType = CommandType.StoredProcedure
> "mlg1906" <mlg1906@.discussions.microsoft.com> wrote in message
> news:86C67AB7-8F4E-42A4-B0C8-CB7FC7DE7CD6@.microsoft.com...
> > I'm developing an intranet site in ASP.NET 2.0 but I can't seem to
> > connect to the DB from within my code. I've created a .vb class that
> > houses a private Connection() that other functions within the class can
> > call to connect to the database. In the calling function, I've declared
> > my connection object and called the "Open" method on the object.
> > However, when I attempt to execute the stored procedure command by
> > calling the "ExecuteScalar" method, I get the following error:
> > "ExecuteScalar requires an open and available Connection. The
> > connection's current state is closed."
> > Here's the code from my class:
> > Imports System.Data
> > Imports System.Data.SqlClient
> > Namespace Encompass
> > Public Class EncompassSecurity
> > Public Shared Function GetHRIDByNTUserID(ByVal strNTUserID) As String
> > Dim strHRID As String
> > 'Create command object
> > Dim cmd As New SqlCommand("usp_Get_HRID_By_NTUserID", Connection())
> > cmd.CommandType = CommandType.StoredProcedure
> > 'Open DB connection
> > Dim DBConnection As SqlConnection = Connection()
> > DBConnection.Open()
> > 'Input parameters
> > Dim inNTUserParam As New SqlParameter("@.NT_UserID", SqlDbType.VarChar)
> > inNTUserParam.Direction = ParameterDirection.Input
> > inNTUserParam.Value = strNTUserID
> > cmd.Parameters.Add(inNTUserParam)
> > 'Output parameters
> > Dim outHRIDParam As New SqlParameter("@.HRID", SqlDbType.Int)
> > outHRIDParam.Direction = ParameterDirection.Output
> > cmd.Parameters.Add(outHRIDParam)
> > 'Run stored procedure
> > strHRID = cmd.ExecuteScalar()
> > Return (strHRID)
> > 'Close DB connection
> > DBConnection.Close()
> > End Function
> > Private Shared Function Connection() As SqlConnection
> > Dim strConnectionString As String
> > strConnectionString = ConfigurationManager.ConnectionStrings(
> > "Conn").ConnectionString
> > Return New SqlConnection(strConnectionString)
> > End Function
> > End Class
> > End
> > Namespace
> > Here's the code from my web.config file:
> > <?
> > xml version="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
> > -->
> > <
> > configuration
> > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> > <
> > connectionStrings>
> > <
> > add name="Conn" connectionString="Data Source=ServerName;Initial
> > Catalog=NPASDV;uid=UserName;password=*******;"
> > providerName="System.Data.SqlClient" />
> > </
> > 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.
> > -->
> > <
> > roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
> > <
> > compilation debug="true" strict="false" explicit="true" />
> > <
> > pages>
> > <
> > namespaces>
> > <
> > clear />
> > <
> > add namespace="System" />
> > <
> > add namespace="System.Collections" />
> > <
> > add namespace="System.Collections.Specialized" />
> > <
> > add namespace="System.Configuration" />
> > <
> > add namespace="System.Text" />
> > <
> > add namespace="System.Text.RegularExpressions" />
> > <
> > add namespace="System.Web" />
> > <
> > add namespace="System.Web.Caching" />
> > <
> > add namespace="System.Web.SessionState" />
> > <
> > add namespace="System.Web.Security" />
> > <
> > add namespace="System.Web.Profile" />
> > <
> > add namespace="System.Web.UI" />
> > <
> > add namespace="System.Web.UI.WebControls" />
> > <
> > add namespace="System.Web.UI.WebControls.WebParts" />
> > <
> > add namespace="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.
> > -->
> > <