找不到类型或命名空间名称“SqlConnection”(是否缺少 using 指令或程序集引用?)

“/OnlineMovies”应用程序中的服务器错误。

编译错误

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

编译器错误消息: CS0246:

源错误:

 
行 29:     {
行 30:         string str = "select top 8 * from Movies order by MovieHit desc";
行 31:         SqlConnection con = DB.getConnection();
行 32:         DataSet ds = new DataSet();
行 33:         SqlDataAdapter sda = new SqlDataAdapter(str, con);


源文件: c:/Users/cai/Documents/Visual Studio 2008/WebSites/OnlineMovies/UserControls/Top.ascx.cs 行:31

F:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE> "C:/Windows/Microsoft.NET/Framework/v3.5/csc.exe" /t:library /utf8output /R:"C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Web.Extensions/3.5.0.0__31bf3856ad364e35/System.Web.Extensions.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Runtime.Serialization/3.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Data.DataSetExtensions/3.5.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll" /R:"C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Web.Mobile/2.0.0.0__b03f5f7f11d50a3a/System.Web.Mobile.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.ServiceModel.Web/3.5.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.IdentityModel/3.0.0.0__b77a5c561934e089/System.IdentityModel.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.WorkflowServices/3.5.0.0__31bf3856ad364e35/System.WorkflowServices.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.ServiceModel/3.0.0.0__b77a5c561934e089/System.ServiceModel.dll" /R:"C:/Windows/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll" /R:"C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll" /R:"C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll" /R:"C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/onlinemovies/2ca61950/2ba85a69/App_Code.n_lij92u.dll" /R:"C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll" /R:"C:/Windows/assembly/GAC_MSIL/System.Xml.Linq/3.5.0.0__b77a5c561934e089/System.Xml.Linq.dll" /out:"C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/onlinemovies/2ca61950/2ba85a69/App_Web_2-xos-to.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/onlinemovies/2ca61950/2ba85a69/App_Web_2-xos-to.0.cs" "C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/onlinemovies/2ca61950/2ba85a69/App_Web_2-xos-to.1.cs" "C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/onlinemovies/2ca61950/2ba85a69/App_Web_2-xos-to.2.cs"


适用于 Microsoft(R) .NET Framework 3.5 版的 Microsoft(R) Visual C# 2008 编译器 3.5.30729.4926
 版
版权所有(C) Microsoft Corporation。保留所有权利。

c:/Users/cai/Documents/Visual Studio 2008/WebSites/OnlineMovies/UserControls/Top.ascx.cs(31,9): error CS0246: 找不到类型或命名空间名称“SqlConnection”(是否缺少 using 指令或程序集引用?)
c:/Users/cai/Documents/Visual Studio 2008/WebSites/OnlineMovies/UserControls/Top.ascx.cs(33,9): error CS0246: 找不到类型或命名空间名称“SqlDataAdapter”(是否缺少 using 指令或程序集引用?)
c:/Users/cai/Documents/Visual Studio 2008/WebSites/OnlineMovies/UserControls/Top.ascx.cs(33,34): error CS0246: 找不到类型或命名空间名称“SqlDataAdapter”(是否缺少 using 指令或程序集引用?)
c:/Users/cai/Documents/Visual Studio 2008/WebSites/OnlineMovies/UserControls/Top.ascx(10,99): error CS1061: “ASP.usercontrols_top_ascx”不包含“DataList2_ItemCommand”的定义,并且找不到可接受类型为“ASP.usercontrols_top_ascx”的第一个参数的扩展方法“DataList2_ItemCommand”(是否缺少 using 指令或程序集引用?)



版本信息: Microsoft .NET Framework 版本:2.0.50727.4961; ASP.NET 版本:2.0.50727.4955

 

 

解决方法:

在错误页后台程序添加如下命名空间

using System.Data.SqlClient

 

你可能感兴趣的:(C#,ASP.NET)