SQL connection issues..

tgabe213

2[H]4U
Joined
Aug 27, 2007
Messages
3,684
Format of the initialization string does not conform to specification starting at index 0.


Original thread here. I was able to get the connection to work within VWD connecting to the remote database, now I get the error bolded above.

Current .aspx page:
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CLA.aspx.cs" Inherits="CLA" %>

<asp:Content ID="Content1" ContentPlaceHolderID="title" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="sitebrand" Runat="Server">
<h1>Commercial Lending</h1>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FormList" Runat="Server">
[B]<asp:SqlDataSource id="srcForms" SelectCommand="SELECT * From CLAdb" connectionString="LendingFormsDB" Runat="server" />
        
        <asp:BulletedList ID="BulletedList1" runat="server"
        DataSourceID="srcForms"
        DataTextField="FormName"
        DataValueField="FormURL"
        DisplayMode="HyperLink">
        </asp:BulletedList>
</asp:Content>[/B]

Current master page
Code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<style type= "text/css">
			
/*CSS for Rollover Information*/

.popup a{position:relative;}/* set stacking context*/
.popup a span{
visibility:hidden;/* hide message initially*/
position:absolute;
top:-100px;
left:0px;
width:250px;
padding:5px;
background:#B0AE67;
color:#000;
border:2px inset #848113;
text-decoration: none;
}
.popup a:hover{visibility:visible}/* ie bug needed to make span show*/
.popup a:hover span{visibility:visible;}/* reveal image*/

/* --End of Rollover CSS -- */
</style>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>
    <asp:ContentPlaceHolder id="title" runat="server">
    </asp:ContentPlaceHolder></title>
    
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>



<body>
<form id="form1" runat="server">

	<div id="header">
		<div id="sitebranding">
		<asp:ContentPlaceHolder id="sitebrand" runat="server">
        </asp:ContentPlaceHolder>
		</div>
		
		<div id="tagline">
			<p>Pre-Closing Customer Contact Forms</p>

				<div id="taglinelinks">
					<a href="mailto:[email protected]">E-Mail here with Questions/Concerns</a>
				</div>
		</div>		
	</div><!--End of Header Div -->
	
	<div id="navigation">
		<ul>
			<p><li><a href="ResourceCLA.html">Pre-Closing Customer Contact Forms</a></li></p>
			<p><li><a href="ResourceCLB.html">Pre-Closing Backroom Forms</a></li></p>
			<p><li><a href="ResourceCLC.html">Closing Documents</a></li></p>
			<p><li><a href="ResourceCLD.html">Post-Closing Documents</a></li></p>
			<p><li><a href="ResourceCLE.html">Form Letters</a></li></p>
			<p><li><a href="ResourceCLF.html">Title and Related Documents</a></li></p>
			<p><li><a href="ResourceCLG.html">Appraisals</a></li></p>
			<p><li><a href="ResourceCLH.html">Repossession Kit</a></li></p>
			<p><li><a href="http://intranet/BusinessConnect/eBCM.asp?filterKey=8&pageKey=9">Back to Commercial Banking Intranet</a></li></p>
		</ul>
	</div> <!-- end of navigation div -->
	
	<div id="bodycontent">
	<h2>Pre-Closing Customer Contact Forms</h2>
	
	<div id="forms">
[B]        <asp:ContentPlaceHolder id="FormList" runat="server">
        </asp:ContentPlaceHolder>[/B]
	</div><!-- End of bodycontent div -->
	
</form>
</body>
</html>

web.config
Code:
<?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>



    <appSettings/>
  [B]<connectionStrings>
    <add name="LendingFormsDB" connectionString="Data Source=intranetdb;DataBase=LendingForms;uid=sa;pwd=123;" providerName="System.Data.SqlClient"/>
  </connectionStrings>[/B]
    <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.
        -->
        <compilation debug="false">

        </compilation>
        <!--
            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>

There is nothing but the default data in the code behinds.
Target framework is set to .net 2.0 in VWD
SQL server 2005 database
Server 2003 with .net 2.0 (which is where the sql database is located)

I am able to connect to the database through VWD, and view the contents, but I get nothing when I 'View in Browser' or load on any page.

Help?
 
Your connection string looks fine in the Web.Config, but it's not being passed into the SqlDataSource object. Look closer at that. Also, I cannot tell if you're intending to use the Web.Config connection string or a DSN in your SqlDataSource object's "ConnectionString" parameter.



Edit: Ok, I saw the "LendingFormsDB" as the name in the connectionStrings collection. You need to reference it like this:
Code:
<asp:SqlDataSource ... ConnectionString="<%$ ConnectionStrings:LendingFormsDB %>" ... />
More details can be found here.
 
Thanks for the quick reply!

Code:
    <connectionStrings>
      <clear/>
      <add name="LendingFormsDB" connectionString="Server=intranetdb;Database=LendingForms;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
    </connectionStrings>

Code:
<asp:SqlDataSource ID="srcForms" runat="server" ConnectionString="<%$ ConnectionStrings:LendingFormsDB %>" SelectCommand="SELECT * From CLAdb" />

New error of System.ArgumentException: Keyword not supported: 'trusted connection'.

I don't even have the Trusted Connection portion in my connection string..I get the same error with and without it.
 
That error is related to the "Integrated Security=SSPI;" part of your connection string.

Depending on how your application is designed in the data lookups and any stored procs, you may want to change "Integrated Security=SSPI;" to instead reference a SQL Server user account to run under.

Also.... The Connection Strings website is a good resource for syntax and examples of different connection strings (and parameters) for a variety of common DB vendors.
 
That error is related to the "Integrated Security=SSPI;" part of your connection string.

Depending on how your application is designed in the data lookups and any stored procs, you may want to change "Integrated Security=SSPI;" to instead reference a SQL Server user account to run under.

Also.... The Connection Strings website is a good resource for syntax and examples of different connection strings (and parameters) for a variety of common DB vendors.

I've seen that site, but at first, being a bit un-familiar with it, it was a bit confusing.

Anyway, I replaced the integrated security with uid=sa;pwd=xxx; to give a complete string of
Code:
    <connectionStrings>
      <clear/>
      <add name="LendingFormsDB" connectionString="Server=intranetdb;Database=LendingForms;uid=sa;pwd=xxx;" providerName="System.Data.SqlClient"/>
    </connectionStrings>
and it still gives the same error.
 
The worst thing is that this is inside of VWD, which I wasn't having any problems yesterday with, and I'm not sure what changed.

Edit

I'm actually getting the same error on the deployment server now.
 
What version of SQL Server are you connecting to?

Edit: OTOH, the fact that it's still complaining about "Trusted Connection" has me wondering:
1 - Whether or not the adjusted Web.Config file actually was promoted to the server, and
2 - If a different connection string is really being pulled and used.
Probably would be good to review all code files on your dev box and server, and look for the phrases "Trusted" or "SSPI".
 
SQL Server 2005 running on Windows Server 2003 with .NET 2.0 framework. The table was built inside of that server, not imported in or anything.
 
SQL Server 2005 running on Windows Server 2003 with .NET 2.0 framework. The table was built inside of that server, not imported in or anything.
Then your connection string should be fine for SQL 2005. In addition to the "OTOH" section from my previous post, I'm also wondering if the SQL Server box was setup to allow "Mixed Mode" authentication.
 
Then your connection string should be fine for SQL 2005. In addition to the "OTOH" section from my previous post, I'm also wondering if the SQL Server box was setup to allow "Mixed Mode" authentication.

If it wasn't setup that way, which would it allow by default? Windows or username/pwd?

The same database worked yesterday inside of Visual Web Developer, but I think a file or two accidentally may have gotten overwritten (they are very very basic to begin with).

It keeps showing the web.config file as being updated at 11:12 this morning (even though I just updated it a 3:05 this afternoon). Going to give that server a reboot.
Edit: It's showing that same time on my production pc as well. It won't show an updated time after saving. I'm 100% sure I have the correct file open, and I'm copy/pasting the correct file from the correct directory.
 
Alright, a few questions/statements now...
Here's what we've got setup. On our Intranet server, everything for the Intranet is on E:. This contains all the files for our intranet, all the forms I've created, and a few directories for a few different things. One of these directories contains an .aspx file that creates a photo album out of the pictures in that directory (aka, aspx works in there). I update my LendingForms directory (which is a folder right next to the photo albums), and I get It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.. I didn't have to create a virtual directory for the photo album, but it works..

However, inside of C:Inetpub/wwwroot, I have the exact same LendingForms directory (just trying to figure out what my problem was), and it works now in there.

Another thing I think is happening, is that VWD might be caching my files (I remember this happening at a demo at the Hero's Happen Here event for VS2008). I have been opening VWD, and selecting my project, and opening that way. This time, I selected the files directly in the folder, and opened them that way, updated the web.config file, and now there is no problem.

So basically, it works within VWD, and it works in the wwwroot on the Intranet server (with userid/pwd authentication), but it gives the previously noted error when trying to open CLA.aspx from the directory I would like to have the final project placed.
 
Well, I deleted the authentication mode = windows portion of the config file (this project will not use any authentication), got an error about the master page (and I just changed the ~/Site.Master to ./Site.Master and she works where I want it to work!
 
Back
Top