首页 新闻 会员 周边

LINQ to SQL:数据库插入记录出现问题!!!

0
悬赏园豆:20 [已关闭问题]

这问题我整晚都无法解决!求各路高手帮忙!不胜感激!

service.aspx的部分代码如下:

<table border="0">
            <tr>
              <td>
                电子邮箱: </td>
              <td align=left class="style2">
                  <asp:TextBox ID="email" runat="server" Width="200px"> </asp:TextBox>
            </td>
            </tr>
            <tr>
              <td>
                标&nbsp;&nbsp;&nbsp;&nbsp;题: </td>
              <td align=left class="style2">
                  <asp:TextBox ID="title" runat="server" Width="200px"> </asp:TextBox>
            </td>
            </tr>
            <tr>
              <td>
                内&nbsp;&nbsp;&nbsp;&nbsp;容: </td>
              <td align=left class="style2">
                  <asp:TextBox ID="message" runat="server" Width="260px" Height="100px"
                      TextMode="MultiLine"> </asp:TextBox>
            </td>
            </tr>
            <tr>
              <td>
                </td>
              <td align=left class="style2">       
            </td>
            </tr>
            <tr>
              <td>
                </td>
              <td align=center class="style2">       
                  <asp:Button ID="sendmessage" runat="server" Text="提交" Width="60px"
                      Height="20px" BackColor="#98A39D" Font-Bold="True" />
            </td>
            </tr>
            </table>


service.aspx.cs的部分代码如下:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class service : System.Web.UI.Page
{
    DAL.austininfoDataContext austininfo = new DAL.austininfoDataContext(@"App_Data\austininfo.mdf");
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void sendmessage_Click(object sender, EventArgs e)
    {
        DAL.messages mymessages = new DAL.messages();
        mymessages.email = email.Text;
        mymessages.title = title.Text;
        mymessages.message = message.Text;
        mymessages.sendtime = Convert.ToString(DateTime.Now);
        austininfo.messages.InsertOnSubmit(mymessages);
        austininfo.SubmitChanges();
    }
}


我按F5调试运行,出现错误页面,如下:

“/”应用程序中的服务器错误。
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误消息: CS0012: 类型“System.Data.Linq.DataContext”在未被引用的程序集中定义。必须添加对程序集“System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

源错误:

行 14: public partial class service : System.Web.UI.Page
行 15: {
行 16:    DAL.austininfoDataContext austininfo = new DAL.austininfoDataContext(@"App_Data\austininfo.mdf");
行 17:    protected void Page_Load(object sender, EventArgs e)
行 18:    {


源文件: f:\SharpPlan\MyProject\austin\WEB\service.aspx.cs    行: 16


希望高手们给出解决办法!

设计无量的主页 设计无量 | 初学一级 | 园豆:80
提问于:2008-09-10 23:56
< >
分享
其他回答(2)
0

添加一下对System.Data.Linq的引用

在你的web项目中右击Reference,然后Add Reference,在标签卡中选System,找到System.Data.Linq,按确定,然后重新编译网站,再试试

Gray Zhang | 园豆:17610 (专家六级) | 2008-09-11 08:19
0

在web.config的configuration/system.web/compilation/assemblies节点里添加一个:

                <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

deerchao | 园豆:8367 (大侠五级) | 2008-09-11 12:44
0

你的项目是不是使用.Net3.5框架??

李永京 | 园豆:3114 (老鸟四级) | 2008-09-14 12:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册