所以我新的匹配使用asp.net用VB.NET和我遇到了此問題:確保此代碼文件中定義的類「繼承」屬性進口
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 1: Imports System.Data.SQLite
Line 2: Imports System.Diagnostics
Source File: C:\Projects\HousingInfo\HousingInfo\SQLiteDatabase.aspx.vb Line: 1
我從我所有的谷歌上搜索認爲它有事情做這一行:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SQLiteDatabase.aspx.vb" Inherits="SQLiteDatabase" %>
這是數據庫的代碼:
Imports System.Data.SQLite
Imports System.Diagnostics
Public Class SQLiteDatabase
Private Shared dbConnection As String
Public Sub New()
dbConnection = "Data Source=housingInfo.db"
CreateTables()
End Sub
Public Sub New(file)
dbConnection = String.Format("Data Source={0}", file)
CreateTables()
End Sub
<System.Web.Services.WebMethod()>
Public Shared Function CreateTables()
Debug.WriteLine("Creating Tables")
Dim connection = New SQLiteConnection(dbConnection)
connection.Open()
Try
Dim stm As String = "CREATE TABLE IF NOT EXISTS houses(id INTEGER PRIMARY KEY AUTOINCREMENT, address TEXT, city TEXT, state TEXT, rented INTEGER)"
Catch ex As Exception
MsgBox("Can't create table: " & ex.Message)
End Try
Return Nothing
End Function
End Class
我很困惑。我的代碼中沒有導入語句嗎?
你是不是繼承的Page或UserControl -class,只是作爲錯誤信息的狀態。添加繼承頁與 – Esko