用户未处理Http Exception:无法连接到SQL Server数据库。 [英] Http Exception was unhandled by the user: Unable to connect to SQL server database.
问题描述
Hello Friends,
其实我正在处理个人资料:我已经创建了一个自定义类并在该类中创建了个人资料属性。
然后我在网络配置文件中继承该对象。
Hello Friends,
Actually i am working on profiles: I have created a custom class and created profile properties in that class.
I am then inheriting that object in the web config file.
namespace shop
{
public class shopping
{
private List<CartItem> _Items = new List<CartItem>();
public List<CartItem> items
{
get { return _Items; }
}
public class CartItem
{
private string _name;
private decimal _price;
private string _description;
public string Name
{
get { return _name; }
set { _name = value; }
}
public decimal Price
{
get { return _price; }
set { _price = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
}
public CartItem()
{
}
public CartItem(string name, decimal price, string description)
{
_name = name;
_price = price;
_description = description;
}
}
public shopping()
{
//
// TODO: Add constructor logic here
//
}
}
}
Web配置:代码
Web Config : code
<profile>
<properties>
<add name="shopping" type="shop.shopping"/>
</properties>
</profile>
页面代码背后:
Page code behind:
void Page_PreRender()
{
gv.DataSource = Profile.shopping.items;
gv.DataBind();
}
public void add(object sender, EventArgs e)
{
shop.shopping.CartItem cart = new shop.shopping.CartItem(name.Text, decimal.Parse(price.Text),desc2.Text);
Profile.shopping.items.Add(cart);
}
- 点击按钮我想要将商品添加到购物车。我怎么能管理它,但主要的是:在呈现页面的那一刻它抛出异常。
- 为什么发生此异常?因为我有我的数据库。它是否与aspnet_regsql工具有关?
请指教,
谢谢和问候,>
Rahul
- On button click i want to add items to the shopping cart. How ever i can manage that, but the main thing is: The moment the page is rendered it throws an Exception.
- Why this exception occured? because i have my data base in place. Is it something related to aspnet_regsql tool?
Please advice,
Thanks and Regards,
Rahul
推荐答案
这篇关于用户未处理Http Exception:无法连接到SQL Server数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!