Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 connection string

Author  Topic 

syed_82
Starting Member

2 Posts

Posted - 2008-12-01 : 07:42:20
Hi everyone,
I am trying my firt project in asp.net 2.0(Visual studio 2005 C#) and sql server 2005. I have bought hosting from csnewmedia. However, after many efforts I am yet to get the result.

I have created the database(db1.mdf) on the hoting site, did backup and restoing as well. But, my url says, erver error in '/' application.

URL www.syed-portfolio.com

I guess the poblem is with the connectionstring in web.config
here is the file
web.config

<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<Driver="{SQL Native Client}" Server="sql2005.ourwindowsnetwork.com;Database=db1; Uid=syed;Pwd=1234"/>
</connectionStrings>
<system.web>
<compilation debug="false"/>
<authentication mode="Windows"/>
<customErrors mode="Off"/>
</system.web>
</configuration>



now default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>test4</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:Label ID="Label1" runat="server" Text="test 4 pc"></asp:Label><br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList> <br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db1ConnectionString %>"
SelectCommand="SELECT * FROM [Student]"></asp:SqlDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="StudentID" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="StudentID" HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" />
<asp:BoundField DataField="Forename" HeaderText="Forename" SortExpression="Forename" />
<asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
</Columns>
<RowStyle BackColor="#E3EAEB" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</form>
</body>
</html>




finally default.aspx.cs


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}


please, let me know what i have done wrong?

syed_82
Starting Member

2 Posts

Posted - 2008-12-01 : 09:41:06
Hi everyone,
finally i managed to make it run. as i guessed, connectionstring was the problem. although, i didnt receive any reply from anyone here, but thanx to those people who atleast read my thread. End of the day, i found the mistake by myself, was a bit of achievement
Go to Top of Page
   

- Advertisement -