This is a visual webpart project with visual studio 2010 and C#. I am a new to this programming and has background in VB. Please help, I have spent two days already trying to fix this error.
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace ConnTest.VisualWebPart1
{
[ToolboxItemAttribute(false)]
public class VisualWebPart1 : WebPart
{
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @"~/_CONTROLTEMPLATES/ConnTest/VisualWebPart1/VisualWebPart1UserControl.ascx";
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
}
}
Server Error in '/' Application.
--------------------------------------------------------------------------------
The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.
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.InvalidOperationException: The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.
Source Error:
Line 179: </SelectedItemTemplate>
Line 180: </asp:ListView>
Line 181: <asp:SqlDataSource ID="SqlDataSource1" runat="server"
Line 182: ConnectionString="<%$ ConnectionStrings:BASKET %>"
Line 183: ProviderName="<%$ ConnectionStrings:BASKET.ProviderName %>"
Source File: c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\ConnTest\VisualWebPart1\VisualWebPart1UserControl.ascx Line: 181
Stack Trace:
[InvalidOperationException: The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.]
System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString(String connectionStringName) +3891621
ASP._controltemplates_conntest_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlSqlDataSource1() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\ConnTest\VisualWebPart1\VisualWebPart1UserControl.ascx:181
ASP._controltemplates_conntest_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlTree(_controltemplates_conntest_visualwebpart1_visualwebpart1usercontrol_ascx __ctrl) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\ConnTest\VisualWebPart1\VisualWebPart1UserControl.ascx:1
ASP._controltemplates_conntest_visualwebpart1_visualwebpart1usercontrol_ascx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7485c400\87b8ec3b\App_Web_visualwebpart1usercontrol.ascx.47e3ab4c.q-1la1my.0.cs:0
System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory objectFactory, VirtualPath virtualPath, Type t, Object[] parameters) +343
System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) +110
ConnTest.VisualWebPart1.VisualWebPart1.CreateChildControls() +95
System.Web.UI.Control.EnsureChildControls() +146
System.Web.UI.Control.PreRenderRecursiveInternal() +61
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456
Ok. I tried that but I still get the same error. Follows the error and all the code.
Server Error in '/' Application.
--------------------------------------------------------------------------------
The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.
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.InvalidOperationException: The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.
Source Error:
Line 188: </SelectedItemTemplate>
Line 189: </asp:ListView>
Line 190: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BASKET %>" SelectCommand="EXEC crdb.p_Lock_Select"></asp:SqlDataSource>
Line 191: </div>
Line 192:</body>
Source File: c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx Line: 190
Stack Trace:
[InvalidOperationException: The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.]
System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString(String connectionStringName) +3891621
ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlSqlDataSource1() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:190
ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlTree(_controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx __ctrl) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:1
ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7485c400\87b8ec3b\App_Web_visualwebpart1usercontrol.ascx.febc5ac.5askyt3r.0.cs:0
System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory objectFactory, VirtualPath virtualPath, Type t, Object[] parameters) +343
System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) +110
VisualWebPartProject1.VisualWebPart1.VisualWebPart1.CreateChildControls() +95
System.Web.UI.Control.EnsureChildControls() +146
System.Web.UI.Control.PreRenderRecursiveInternal() +61
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456
System.InvalidOperationException was unhandled by user code
Message=The connection name 'BASKET' was not found in the applications configuration or the connection string is empty.
Source=System.Web
StackTrace:
at System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString(String connectionStringName)
at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlSqlDataSource1() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:line 190
at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlTree(_controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx __ctrl) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:line 1
at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7485c400\87b8ec3b\App_Web_visualwebpart1usercontrol.ascx.febc5ac.5askyt3r.0.cs:line 0
at System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory objectFactory, VirtualPath virtualPath, Type t, Object[] parameters)
at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
at VisualWebPartProject1.VisualWebPart1.VisualWebPart1.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
//VisualWebPart1.cs
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace VisualWebPartProject1.VisualWebPart1
{
[ToolboxItemAttribute(false)]
public class VisualWebPart1 : WebPart
{
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @"~/_CONTROLTEMPLATES/VisualWebPartProject1/VisualWebPart1/VisualWebPart1UserControl.ascx";
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
}
}
//VisualWebPart1UserControl.ascx.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Dts.Runtime;
namespace VisualWebPartProject1.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
}
}
I was looking at web.config in my project directory. I need to update existing web.config on the sharepoint. The way to find it is to go through IIS, share point website and then browse site. web.config is in the root folder. Adding the connection string
there would take care of the issue. I will close the issue. Thanks for your help.
Marked as answer by prmody on Mar 16, 2012 11:00 PM
prmody
Member
8 Points
14 Posts
Need help with error: The connection name 'BASKET' was not found in the applications configuratio...
Mar 16, 2012 05:17 PM|LINK
web.config code below.<?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <remove name="BASKET" /> <add name="BASKET" connectionString="Data Source=SABODDB04;Initial Catalog=BASKET;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration>VisualWebPartUserControl.ascx code is below.
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs" Inherits="ConnTest.VisualWebPart1.VisualWebPart1UserControl" %> <%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %> <html> <head> <title>Connection Test</title> </head> <body> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" EnableModelValidation="True"> <AlternatingItemTemplate> <tr style="background-color: #FAFAD2;color: #284775;"> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </AlternatingItemTemplate> <EditItemTemplate> <tr style="background-color: #FFCC66;color: #000080;"> <td> <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" /> </td> <td> <asp:Label ID="Lock_IdLabel1" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Bind("Lock") %>' /> </td> <td> <asp:TextBox ID="Month_End_DateTextBox" runat="server" Text='<%# Bind("Month_End_Date") %>' /> </td> <td> <asp:TextBox ID="User_NameTextBox" runat="server" Text='<%# Bind("User_Name") %>' /> </td> <td> <asp:TextBox ID="Create_DateTextBox" runat="server" Text='<%# Bind("Create_Date") %>' /> </td> </tr> </EditItemTemplate> <EmptyDataTemplate> <table runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;"> <tr> <td> No data was returned.</td> </tr> </table> </EmptyDataTemplate> <InsertItemTemplate> <tr style=""> <td> <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" /> </td> <td> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Bind("Lock") %>' /> </td> <td> <asp:TextBox ID="Month_End_DateTextBox" runat="server" Text='<%# Bind("Month_End_Date") %>' /> </td> <td> <asp:TextBox ID="User_NameTextBox" runat="server" Text='<%# Bind("User_Name") %>' /> </td> <td> <asp:TextBox ID="Create_DateTextBox" runat="server" Text='<%# Bind("Create_Date") %>' /> </td> </tr> </InsertItemTemplate> <ItemTemplate> <tr style="background-color: #FFFBD6;color: #333333;"> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </ItemTemplate> <LayoutTemplate> <table runat="server"> <tr runat="server"> <td runat="server"> <table ID="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"> <tr runat="server" style="background-color: #FFFBD6;color: #333333;"> <th runat="server"> Lock_Id</th> <th runat="server"> Lock</th> <th runat="server"> Month_End_Date</th> <th runat="server"> User_Name</th> <th runat="server"> Create_Date</th> </tr> <tr ID="itemPlaceholder" runat="server"> </tr> </table> </td> </tr> <tr runat="server"> <td runat="server" style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;"> </td> </tr> </table> </LayoutTemplate> <SelectedItemTemplate> <tr style="background-color: #FFCC66;font-weight: bold;color: #000080;"> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </SelectedItemTemplate> </asp:ListView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BASKET %>" SelectCommand="EXEC crdb.p_Lock_Select"></asp:SqlDataSource> </body> </html>VisualWebPart1.cs code below.using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace ConnTest.VisualWebPart1 { [ToolboxItemAttribute(false)] public class VisualWebPart1 : WebPart { // Visual Studio might automatically update this path when you change the Visual Web Part project item. private const string _ascxPath = @"~/_CONTROLTEMPLATES/ConnTest/VisualWebPart1/VisualWebPart1UserControl.ascx"; protected override void CreateChildControls() { Control control = Page.LoadControl(_ascxPath); Controls.Add(control); } } }webpart config Connection sharepoint
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Need help with error: The connection name 'BASKET' was not found in the applications configur...
Mar 16, 2012 06:22 PM|LINK
I would take the remove name out of it. Just put that section in liek this because the name doesn't exist anyway:
<connectionStrings> <add name="BASKET" connectionString="Data Source=SABODDB04;Initial Catalog=BASKET;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>webpart config Connection sharepoint
prmody
Member
8 Points
14 Posts
Re: Need help with error: The connection name 'BASKET' was not found in the applications configur...
Mar 16, 2012 06:58 PM|LINK
Ok. I made the change as suggested. Still it does not solve the problem. Follows the new web.config.
<?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="BASKET" connectionString="Data Source=SABODDB04;Initial Catalog=BASKET;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration>bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Need help with error: The connection name 'BASKET' was not found in the applications configur...
Mar 16, 2012 07:08 PM|LINK
Drop provider name from your SqlDataSource control
prmody
Member
8 Points
14 Posts
Re: Need help with error: The connection name 'BASKET' was not found in the applications configur...
Mar 16, 2012 07:34 PM|LINK
Ok. I tried that but I still get the same error. Follows the error and all the code.
System.InvalidOperationException was unhandled by user code Message=The connection name 'BASKET' was not found in the applications configuration or the connection string is empty. Source=System.Web StackTrace: at System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString(String connectionStringName) at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlSqlDataSource1() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:line 190 at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.__BuildControlTree(_controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx __ctrl) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1\VisualWebPart1\VisualWebPart1UserControl.ascx:line 1 at ASP._controltemplates_visualwebpartproject1_visualwebpart1_visualwebpart1usercontrol_ascx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7485c400\87b8ec3b\App_Web_visualwebpart1usercontrol.ascx.febc5ac.5askyt3r.0.cs:line 0 at System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory objectFactory, VirtualPath virtualPath, Type t, Object[] parameters) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at VisualWebPartProject1.VisualWebPart1.VisualWebPart1.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException://VisualWebPart1.cs using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace VisualWebPartProject1.VisualWebPart1 { [ToolboxItemAttribute(false)] public class VisualWebPart1 : WebPart { // Visual Studio might automatically update this path when you change the Visual Web Part project item. private const string _ascxPath = @"~/_CONTROLTEMPLATES/VisualWebPartProject1/VisualWebPart1/VisualWebPart1UserControl.ascx"; protected override void CreateChildControls() { Control control = Page.LoadControl(_ascxPath); Controls.Add(control); } } }<!--VisualWebPart1UserControl.ascx--> <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs" Inherits="VisualWebPartProject1.VisualWebPart1.VisualWebPart1UserControl" %> <%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %> <!--Code above this line is the original code generated by the sytem--> <html> <head> <title>CRDB Locks </title> </head> <body> <h2> Use this page to create new locks, or update existing locks on CRDB data </h2> <hr /> <div> <asp:ListView ID="ListView2" runat="server" DataSourceID="SqlDataSource1" EnableModelValidation="True"> <AlternatingItemTemplate> <tr style=""> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </AlternatingItemTemplate> <EditItemTemplate> <tr style=""> <td> <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" /> </td> <td> <asp:Label ID="Lock_IdLabel1" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Bind("Lock") %>' /> </td> <td> <asp:TextBox ID="Month_End_DateTextBox" runat="server" Text='<%# Bind("Month_End_Date") %>' /> </td> <td> <asp:TextBox ID="User_NameTextBox" runat="server" Text='<%# Bind("User_Name") %>' /> </td> <td> <asp:TextBox ID="Create_DateTextBox" runat="server" Text='<%# Bind("Create_Date") %>' /> </td> </tr> </EditItemTemplate> <EmptyDataTemplate> <table runat="server" style=""> <tr> <td> No data was returned.</td> </tr> </table> </EmptyDataTemplate> <InsertItemTemplate> <tr style=""> <td> <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" /> </td> <td> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Bind("Lock") %>' /> </td> <td> <asp:TextBox ID="Month_End_DateTextBox" runat="server" Text='<%# Bind("Month_End_Date") %>' /> </td> <td> <asp:TextBox ID="User_NameTextBox" runat="server" Text='<%# Bind("User_Name") %>' /> </td> <td> <asp:TextBox ID="Create_DateTextBox" runat="server" Text='<%# Bind("Create_Date") %>' /> </td> </tr> </InsertItemTemplate> <ItemTemplate> <tr style=""> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </ItemTemplate> <LayoutTemplate> <table runat="server"> <tr runat="server"> <td runat="server"> <table ID="itemPlaceholderContainer" runat="server" border="0" style=""> <tr runat="server" style=""> <th runat="server"> Lock_Id</th> <th runat="server"> Lock</th> <th runat="server"> Month_End_Date</th> <th runat="server"> User_Name</th> <th runat="server"> Create_Date</th> </tr> <tr ID="itemPlaceholder" runat="server"> </tr> </table> </td> </tr> <tr runat="server"> <td runat="server" style=""> </td> </tr> </table> </LayoutTemplate> <SelectedItemTemplate> <tr style=""> <td> <asp:Label ID="Lock_IdLabel" runat="server" Text='<%# Eval("Lock_Id") %>' /> </td> <td> <asp:CheckBox ID="LockCheckBox" runat="server" Checked='<%# Eval("Lock") %>' Enabled="false" /> </td> <td> <asp:Label ID="Month_End_DateLabel" runat="server" Text='<%# Eval("Month_End_Date") %>' /> </td> <td> <asp:Label ID="User_NameLabel" runat="server" Text='<%# Eval("User_Name") %>' /> </td> <td> <asp:Label ID="Create_DateLabel" runat="server" Text='<%# Eval("Create_Date") %>' /> </td> </tr> </SelectedItemTemplate> </asp:ListView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BASKET %>" SelectCommand="EXEC crdb.p_Lock_Select"></asp:SqlDataSource> </div> </body> </html><!--Web.config--> <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="BASKET" connectionString="Data Source=SABODDB04;Initial Catalog=BASKET;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration>//VisualWebPart1UserControl.ascx.cs using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data; using System.Data.SqlClient; using Microsoft.SqlServer.Dts.Runtime; namespace VisualWebPartProject1.VisualWebPart1 { public partial class VisualWebPart1UserControl : UserControl { } }prmody
Member
8 Points
14 Posts
Re: Need help with error: The connection name 'BASKET' was not found in the applications configur...
Mar 16, 2012 11:00 PM|LINK
I was looking at web.config in my project directory. I need to update existing web.config on the sharepoint. The way to find it is to go through IIS, share point website and then browse site. web.config is in the root folder. Adding the connection string there would take care of the issue. I will close the issue. Thanks for your help.