If you want to use 2.0 syntax, try this :
In web.config :
<connectionStrings>
<add name="selectDocs"
connectionString="your_connection_string"
providerName="System.Data.SqlClient" />
</connectionStrings>
To display it in an aspx page :
<%@ Page Language="vb" %>
<HTML>
<HEAD>
<title>Retrieving a Connection String with ASP.NET 2.0</title>
</HEAD>
<body>
<form id="Form1" runat="server">
<asp:label id="key1" runat="server" /><br/>
<asp:Literal runat="server" Text="<%$ ConnectionStrings:selectDocs%>" />
</form>
</body>
</HTML>
You can use : <%$ ConnectionStrings:selectDocs%>
to insert the text of your connection string anywhere you want to.
You can also use AppSettings.
If you have this AppSettings key in web.config :
<appSettings>
<add key="SQLConnection" value="server=localhost;trusted_connection=true;da tabase=pubs"/>
</appSettings>
You can retrieve it with :
Dim MyKey As String = ConfigurationSettings.AppSettings("SQLConnection")
and insert MyKey.Text anywhere you wantto.
Juan T. Llibre, asp.net MVP
aspnetfaq.com :
http://www.aspnetfaq.com/
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
===================================
"Darrel" <no*****@nospam.com> wrote in message news:OT**************@TK2MSFTNGP02.phx.gbl...
I doubt you'll be able to tackle encryption right now. You have to first
figure out how to make a connection.
Have you submitted a web search using the terms: test connection string vb.net
I can't even get my DB query function to accept the connection string as a string in 2.0 ;o)
Maybe the issue is my 'antiquated 1.1' DB functions. This is what I have:
======================================
Dim strConnect As ConnectionStringSettings
strConnect = ConfigurationManager.ConnectionStrings("DBConn")
'the above is not working, obviously
Dim strChk As String
Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect.ToStr ing())
objConnect.Open()
strChk = "SELECT name, pwd FROM pf_users WHERE name = ? AND pwd = ? AND admin = 1"
Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect)
Dim objOleDbAdapter As New System.Data.OleDb.OleDbDataAdapter
objCommand.Parameters.Add("@name", System.Data.OleDb.OleDbType.VarChar).Value = strUser
objCommand.Parameters.Add("@pwd", System.Data.OleDb.OleDbType.VarChar).Value = strPwd
objOleDbAdapter.SelectCommand = objCommand
objOleDbAdapter.Fill(DS, "users")
======================================
-Darre;