473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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("@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

Apr 5 '06 #1
5 1422
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" <ml*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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

Apr 5 '06 #2

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" <ml*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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


Apr 5 '06 #3
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" <ml*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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>
<!--

Apr 5 '06 #4

--
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" <ml*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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.
-->
<

Apr 5 '06 #5
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" <ml*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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.
-->
<

Apr 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
15
by: Peroq | last post by:
Hi all I'm not sure ASP is the problem, but my SQL statement seems fine to me. This works fine : strSQL = "SELECT .* FROM _RechPat INNER JOIN NivPatri ON .cod_niv = NivPatri.cod_niv WHERE...
14
by: BlackHawke | last post by:
My Name is Nick Soutter, I am the owner of a small game company, Aepox Games (We're in the middle of a name change from "Lamar Games"), www.lamargames.net. Our first commercial game,...
14
by: jj | last post by:
Is it possible to call a remote php script from within Access? I'm thinking something like: DoCMD... http://www.domain.com/scripts/dataquery.php DoCmd.OpenQuery "update_data", acNormal, acEdit...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
18
by: Jon Delano | last post by:
Hey all I am building a new computer. I have Windows XP Pro with SP2 and all the updates. I installed VS 2003. Then copied a project from my old computer to the new one. When I try and run...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
3
by: lopedon | last post by:
I've got a performance issue in Access 2000 running on Windows 2000. Opening a table local to the MDB takes about 1-2 seconds normally. If I log out of the windows profile that is normally used on...
5
by: kimtherkelsen | last post by:
Hi, I use the System.Data.OleDb.OleDbConnection class to establish a connection to a Oracle 10G database. The dsn connection string I use look like this: dsn=provider="MSDAORA.1";User...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.