Connecting Tech Pros Worldwide Forums | Help | Site Map

how to use WebPart in asp.net2.0

Newbie
 
Join Date: May 2007
Posts: 28
#1: Oct 11 '07
Hi frds
i hav used webparts in my application and i'm using sqlserver2000
when i run the application the following error is displayed

"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) "

this is my html code:

<legend>Simple WebPart Demo</legend>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged">
<asp:ListItem>Browse</asp:ListItem>
<asp:ListItem>Design</asp:ListItem>
</asp:DropDownList>&nbsp; Select design mode.You will be able to drag the calendar from the
FirstWebPartZone to the SecondWebPartZone.
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>
<asp:WebPartZone ID="FirstWebPartZone" runat="server" Width="214px" EmptyZoneText="Add a Web Part to this zone by dropping it here." EnableViewState="False">
<ZoneTemplate>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC"
BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana"
Font-Size="8pt" ForeColor="#003399" Height="200px" Width="220px">
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<WeekendDayStyle BackColor="#CCCCFF" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
</asp:Calendar>
</ZoneTemplate>
<CloseVerb Visible="False" />
<MinimizeVerb Visible="False" />
<RestoreVerb Visible="False" />
</asp:WebPartZone>
<asp:WebPartZone ID="SecondWebPartZone" runat="server" EmptyZoneText="Add a Web Part to this zone by dropping it here."
EnableViewState="False" Width="236px">
<CloseVerb Visible="False" />
<MinimizeVerb Visible="False" />
<RestoreVerb Visible="False" />
</asp:WebPartZone>

this is the code in codebehind(vb):

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
System.Threading.Thread.CurrentThread.CurrentCultu re = New System.Globalization.CultureInfo("en-us")
System.Threading.Thread.CurrentThread.CurrentUICul ture = New System.Globalization.CultureInfo("en-us")
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Select Case Me.DropDownList1.SelectedValue
Case "Browse"
Me.WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode
Case "Design"
Me.WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode
End Select
End Sub

I don't where i'm going wrong
when i searched for this i came to know that we have to provide a membership provider to handle with sqlserver2000
but wat is the code that to be added

how to make sqlserver2000 to be used by the application
plz help me i tried but i couldn't get the result
thank u
archu

Newbie
 
Join Date: May 2007
Posts: 28
#2: Oct 12 '07

re: how to use WebPart in asp.net2.0


Hi frds

I got the solution

Actually in my sqlserver 2000 I don't have "aspnedb" database

to have this

1)go to C:\windows\Microsoft.NET\Framework\version\

in this select aspnet_regsql.exe

when u select this a wizard will be opened select the required one, and by deafult databse="default"

note:if u wont change this then by default it will giv name as aspnetDb

2)click finish

then it will create a database with name "aspnetDb"

3) now go to ur application open web.config file and add the following statements

<connectionStrings>
<add name="MyDb" connectionString="Data Source=YourServer;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SQLClient"/>
</connectionStrings>
<system.web>
<webParts enableExport="true">
<personalization defaultProvider="MyWebPartsProvider">
<providers>
<add name="MyWebPartsProvider" connectionStringName="MyDb" type="System.Web.UI.WebControls.WebParts.SqlPerson alizationProvider"/>
</providers>
</personalization>
</webParts>

<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider,Sy stem.Web, Version=2.0.0.0,&#xA;Culture=neutral,PublicKeyToke n=b03f5f7f11d50a3a" connectionStringName="MyDb" applicationName="/CustomConnection"/>
</providers>
</membership>
</system.web>



4)now run da application

i don't know whats the use of "personalization and membership" my problem solved

can anyone tell what is the use of those those 2 elements

thank u

Archu
Reply


Similar .NET Framework bytes