0

我作为本科生在 Visual Studio 08 工作过,我想开始在 Visual Studio 12 中开发我当时的项目。我该怎么做...没有导入 .mdf 文件的选项。

任何帮助将不胜感激。

我得到了上述问题的答案,我连接了数据库,但是当我运行代码时它给了我一个错误。

我正在尝试在 Visual Basic 中制作一个 Web 应用程序。

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim Conn As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim password As String
        password = Encrypt(TextBox2.Text, "&%#@?,:*")
        'Queries
        Dim query As String = "select * from Registration where username='" & TextBox1.Text & "' and password='" & password & "'"
        Dim SQLConn As New SqlConnection(Conn)
        Dim SQLCmd As New SqlCommand(query, SQLConn)
        SQLConn.Open()

        Dim dr As SqlDataReader
        dr = SQLCmd.ExecuteReader()
        dr.Read()
        ' If Present in databse it will enter here
        If dr.HasRows Then

            ' Remember Session
            'Session("viewid") = dr("userid")
            Session("userid") = dr("userid")
            Session("username") = dr("username")
            Session("email") = dr("email")
            'Remember Me on this pc
            If CheckBox1.Checked Then
                Response.Cookies("UserName").Value = dr("username")
                Response.Cookies("UserName").Expires = DateTime.Now.AddMonths(1)
            End If
            Response.Redirect("Home.aspx")
        End If
        SQLConn.Close()
        Label4.Text = "* Incorrect Username/ Password/ Mode. Re-enter!"
    End Sub

它在 SQLConn.Open() 处给了我一个错误:

SqlException 未被用户代码处理

连接到 SQL Server 的用户实例时,不允许使用用户实例登录标志。连接将被关闭。

有人可以告诉我需要做什么吗?

4

1 回答 1

0

我想您尝试在 SQL Server 上附加您的数据库文件?Windows 7下也有类似的问题,是安装SQL时安全权限无效造成的。

解决方法是删除一个目录,如果缺少该目录会自动重新创建:
删除 C:\Documents and Settings\USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS。

但是我真的不知道在Win8上是不是同样的原因。

希望这有助于塞尔

于 2012-12-06T23:43:12.947 回答