Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP.Net problem

Posted on 2014-02-04
13
682 Views
Last Modified: 2014-02-17
Hello,

I am new'ish to asp.net and I'm trying to connect to a MS SQL database with my provider who is 1and1.com.

When running my very simple asp page I get this error:

------------------------ BEGIN

Server Error in '/' Application.

Parser Error
  Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

 Parser Error Message: Could not load type 'HelloWebForms._Default'.

Source Error:

Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="HelloWebForms._Default" %>
Line 2:  
Line 3:  <!DOCTYPE html>
 


----------------------------------- END

the code in the default.aspx is like this:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="HelloWebForms._Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True"  AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." GridLines="Vertical">
            <AlternatingRowStyle BackColor="#DCDCDC" />
            <Columns>
                <asp:BoundField DataField="FID" HeaderText="FID" SortExpression="FID" Visible="False" />
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#0000A9" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#000065" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FriendsConnectionString1 %>" ProviderName="<%$ ConnectionStrings:FriendsConnectionString1.ProviderName %>" SelectCommand="SELECT [FID], [Name], [Address], [Phone], [Email] FROM [Friends]"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Open in new window


Any ideas why this is happening and how I resolve it?

If you have a working example from 1and1 then I'd gladly take that as well.

Thanks
~j
0
Comment
Question by:prosit
  • 6
  • 5
  • 2
13 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39833132
As the first step I suggest to troubleshoot your data source.

Do that by testing in in code behind(VB file) instead of HTML file.


So:

1: put a button on the form
2: Add code the button so it defines a Sqlconnection and connection string and then open the connections.

Make sure above works. If it does work then you can add it to the HTML.


Also in your html you have:

ConnectionStrings:FriendsConnectionString1 %>

I don't see anywhere you have defined FriendsConnectionString1.
0
 
LVL 2

Author Comment

by:prosit
ID: 39833162
It's in the web.config file:

    <connectionStrings>
        <add name="FriendsConnectionString1" connectionString="Data Source=dbxxxxx.db.1and1.com;Initial Catalog=dbxxxxx;user id=dboxxxxx;password=xxxxxx" providerName="System.Data.SqlClient" />
    </connectionStrings>

~j
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39833207
Please post your code behind page or at least the top of it as the error seems to be referring to the fact it can't load the partial class defined in your Page declaration :

Inherits="HelloWebForms._Default
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 2

Author Comment

by:prosit
ID: 39833226
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.EventArgs

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
End Class

Open in new window

0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39833240
OK it is in the web.config however does your program read and sets it?

specifying connection string in the web.config is not enough. Your code should read it.
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 39833244
Your codebehind class is called _default so in your page declaration you should be inheriting the partial class "_default"

change Inherits="HelloWebForms._Default" in your page declaration to :

Inherits="_Default"
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39833255
@unknown_routine

using ConnectionStrings:FriendsConnectionString1 is how you read a connectionstring setup in the web.config.
0
 
LVL 2

Author Comment

by:prosit
ID: 39833362
Paul Jackson:

Same error...

Could not load type '_Default'.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39833420
Is this a website or web application project, if it's a website project in your page declaration try changing :

CodeBehind="Default.aspx.vb"

to :

CodeFile="Default.aspx.vb"
0
 
LVL 2

Author Comment

by:prosit
ID: 39834151
It's developed in visual studio 2012, I'm not sure I understand the difference between a web-app and a website?

I thought it was kind of the same, except a webapp typically connects to a database.

Please correct me...
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39834264
the main difference between web site projects and web application projects is that web application projects are precompiled before being published to the server whereas web site projects require all code files to be copied to the server which are then compiled by the server when they first get requested.

If it is a web application the project icon is rectangular window like icon and in the solution explorer just under the project folder should be a my project folder with an icon like a spanner.

web application project

If it is a web site project the project icon looks like a globe and in the solution explorer there will be a bin folder.

web site project
A web site project is created by selecting from the File menu in Visual studio, the New Web Site option.
A web application project is created by selecting from the File menu in Visual Studio, the New Project option and then selecting the appropriate Web Application template.

Both types of project can connect to a database and are very similar other than the fact the one is pre-compiled (web application) and the other is compiled on demand.

Web site projects where originally the only type of web project that was available prior to .net 2.0 framework, web application projects became available after the release of .net 2.0 framework.

To refer to the code-behind file in web applications use :
CodeBehind =
in web sites use :
CodeFile =
0
 
LVL 2

Author Comment

by:prosit
ID: 39847445
It seems I'm actually unable to connect using a web.config file with 1and1... POS :)

I'll do a little more research and reward points shortly.

tnx
~j
0
 
LVL 2

Author Closing Comment

by:prosit
ID: 39866518
Seems my internet provider doesn't let me fiddle with it...

thanks anyway!

~j
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question