代码如下:
using System;
using System.Configuration;
using System.Data;
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.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn =new SqlConnection("Data Source=1c4dcbc9ad2c4a0\\SQL2000;Initial catalog=class1; persist Security Info=True;User ID=sa;password=sa");
string strSql = "select * from news where id=3";
conn Open;
SqlDataAdapter sda = new SalDataAdapter(strSql,conn);
conn Close;
DataSet ds = new DataSet();
sda.Fill(ds,"news");
Label1.Text = ds.Tables["news"].Rows[0]["title"].ToString();
}
}
编译器错误消息: CS0246: 找不到类型或命名空间名称“CodeDom”(是否缺少 using 指令或程序集引用?)
源错误:
行 16: SqlConnection CodeDom = new SqlConnection("Data Source=1c4dcbc9ad2c4a0\\SQL2000;Initial catalog=class1; persist Security Info=True;User ID=sa;password=sa"); 行 17: string strSql = "select * from news where id=3"; 行 18: CodeDom Open; 行 19: SqlDataAdapter sda = new SalDataAdapter(strSql,conn); 行 20: CodeDom Close; |
源文件: f:\网站\class1\Default.aspx.cs 行: 18
显示详细的编译器输出:
f:\Microsoft Visual Studio 9.0\Common7\IDE> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.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\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.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.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\class1\29133d9a\87969ebc\App_Web_qnxqptyg.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\class1\29133d9a\87969ebc\App_Web_qnxqptyg.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\class1\29133d9a\87969ebc\App_Web_qnxqptyg.1.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\class1\29133d9a\87969ebc\App_Web_qnxqptyg.2.cs" Microsoft (R) Visual C# 2005 编译器 版本 8.00.50727.3053 用于 Microsoft (R) Windows (R) 2005 Framework 版本 2.0.50727 版权所有(C) Microsoft Corporation 2001-2005。保留所有权利。 f:\网站\class1\Default.aspx.cs(18,9): error CS0246: 找不到类型或命名空间名称“CodeDom”(是否缺少 using 指令或程序集引用?) f:\网站\class1\Default.aspx.cs(19,34): error CS0246: 找不到类型或命名空间名称“SalDataAdapter”(是否缺少 using 指令或程序集引用?) f:\网站\class1\Default.aspx.cs(19,56): error CS0103: 当前上下文中不存在名称“conn” f:\网站\class1\Default.aspx.cs(20,9): error CS0246: 找不到类型或命名空间名称“CodeDom”(是否缺少 using 指令或程序集引用?) |