我的文件App_Data
夹中有数据库文件,我的网络配置如下所示
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="TicketsConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Tickets.mdf;Integrated Security=SSPI;User Instance=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
</configuration>
我有Default.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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:TextBox ID="LastName" runat="server"></asp:TextBox>
<asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
<asp:TextBox ID="Phone1" runat="server"></asp:TextBox>
<asp:TextBox ID="Phone2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<br />
<asp:Label ID="DisplayMessage" runat="server" style="color: #FF0000" Visible="false" />
<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsConnectionString %>" SelectCommand="SELECT * FROM [Employee]" DeleteCommand="DELETE FROM [Employee] WHERE [EmpID] = @EmpID" InsertCommand="INSERT INTO [Employee] ([LastName], [FirstName], [Phone1], [Phone2]) VALUES (@LastName, @FirstName, @Phone1, @Phone2)" UpdateCommand="UPDATE [Employee] SET [LastName] = @LastName, [FirstName] = @FirstName, [Phone1] = @Phone1, [Phone2] = @Phone2 WHERE [EmpID] = @EmpID">
<DeleteParameters>
<asp:Parameter Name="EmpID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Phone1" Type="String" />
<asp:Parameter Name="Phone2" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Phone1" Type="String" />
<asp:Parameter Name="Phone2" Type="String" />
<asp:Parameter Name="EmpID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataKeyNames="EmpID" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Vertical">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="EmpID" HeaderText="EmpID" InsertVisible="False" ReadOnly="True" SortExpression="EmpID" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="Phone1" HeaderText="Phone1" SortExpression="Phone1" />
<asp:BoundField DataField="Phone2" HeaderText="Phone2" SortExpression="Phone2" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</div>
</form>
</body>
</html>
和一个Default.aspx.cs页面
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataBind();
}
string connectionString = ConfigurationManager.ConnectionStrings["TicketsConnectionString"].ConnectionString;
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("InsertIntoEmployee", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = LastName.Text;
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar);
cmd.Parameters.Add("@Phone1", SqlDbType.NVarChar);//SqlDbType.NVarChar allowed to insert Russian letters
cmd.Parameters.Add("@Phone2", SqlDbType.NVarChar);
cmd.Parameters["@LastName"].Value = LastName.Text;
cmd.Parameters["@FirstName"].Value = FirstName.Text;
cmd.Parameters["@Phone1"].Value = Phone1.Text;
cmd.Parameters["@Phone2"].Value = Phone2.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
DisplayMessage.Text = "袟邪锌懈褋褜 写芯斜邪胁谢械薪邪.";
DisplayMessage.Visible = true;
}
}
并抛出此错误
The database 'G:\SITES\WEBSITE6\APP_DATA\TICKETS.MDF' cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'G:\SITES\WEBSITE6\APP_DATA\TICKETS.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file G:\sites\WebSite6\App_Data\Tickets.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The database 'G:\SITES\WEBSITE6\APP_DATA\TICKETS.MDF' cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'G:\SITES\WEBSITE6\APP_DATA\TICKETS.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file G:\sites\WebSite6\App_Data\Tickets.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
Line 14: protected void Page_Load(object sender, EventArgs e)
Line 15: {
Line 16: GridView1.DataBind();
Line 17: }
Line 18:
我以为连接字符串有问题,但对我来说一切看起来都很好,我的问题如何解决此问题?
版本706是来自Sql Server 2012
的数据库文件版本665是来自Sql Server 2008R2的数据库文件(发布SP1吗?)
http://conceptdev.blogspot.com/2009/04/mdf-cannot-be-opened-because-
it-is.html
问题内容: 当我尝试运行我的网站(使用aspx)时,出现此问题: System.Data.dll中发生类型为’System.Data.SqlClient.SqlException’的异常,但未在用户代码中处理 附加信息:由于数据库版本为706,因此无法打开数据库“ C:\ USERS \ XXXX \ DESKTOP \ BERMAN \ APP_DATA \ DATABASE.MDF”。此服务器
Gson提供了注解来控制基于其各种版本的类的Json序列化/反序列化。 考虑以下具有版本支持的类。 在这个类中,我们最初定义了两个变量和,稍后将其添加为一个新变量。 使用定义了,名称从版本开始并经过验证,版本为。 GsonBuilder提供了方法来序列化这样的版本化类。 让我们来看一个实际版本支持的例子。 创建一个名为的Java类文件:GsonTester.java - 执行上面示例代码,得到以下
我试图编译GLSL着色器在LWJGL使用OpenGL。我在MacOS Sierra上。 尝试编译着色器时出现以下错误: 着色器代码在Windows上工作,但在macOS上测试时却不能。下面是着色器代码: 下面是我如何加载着色器。。。 print语句返回正确的输出,但它仍然给我错误。 我在stackoverflow上下搜索了一个解决方案,但每个人都说他们在编译它时没有换行符,我有。我不明白为什么会这
我使用的是IntelliJ IDEA Ultimate 2019.3.1。每当我尝试启动任何简单的Java Maven项目(甚至可能是一个简单的Hello World)时,我都会得到以下错误: 通过终端运行,得到以下输出: 通过终端运行,得到以下输出:
我目前正试图在代码中使用一个经过定制培训的OpenNLP名称查找器模型。我的项目使用OpenNLP1.6.0,并使用EclipseIDE开发。该模型还使用OpenNLP 1.6.0进行了训练。 然而,我遇到了一个恼人的错误: 这里有人问了一个类似的问题,答案说问题是由于OpenNLP模型使用与使用中的版本相同的版本进行训练(即,使用1.6.0训练模型,并在同样使用1.6.0的项目中使用它)。然而,
我刚刚安装了3.0使用在我的笔记本电脑上,这是运行14.04: 然而,当我使用时,终端似乎认为它使用的是1.2版。1: 更糟糕的是,当我去打开一个JSON nbform版本4的笔记本,它支持IPython3.0,我得到以下错误: 我试图使用团队推荐的命令将笔记本降级到版本3,但对我来说也失败了: 这到底是怎么回事?