近日自己做了一个asp.net的网站,想找个空间弄上去看看,http://vwdhosting.net在上面注册了一个空间,传上去之后就出现这个问题,几乎每个页面都出现了,但是在本机运行的时候完全正常,有些页面能读取出数据,但只要有DataTable绑定数据的地方就出错,在其它页用String返回的时候行.数据库用的是Access 2003简体中文版,编程环境是Microsoft Visual Studio 2005,数据库连接用的是OLEDB
已经是第二次问这个问题了,希望能得一解,要是分不够,只要能解决问题,分可再加.Server Error in '/' Application.
--------------------------------------------------------------------------------Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1502: The best overloaded method match for 'System.Data.DataView.DataView(System.Data.DataTable)' has some invalid argumentsSource Error: Line 28: CurPage = 1;
Line 29: //DataTable dt = DB.getShowNewsDataSource();
Line 30: DataView dv = new DataView(DB.getShowNewsDataSource());
Line 31: PagedDataSource ps = new PagedDataSource();
Line 32: ps.DataSource = dv;
已经是第二次问这个问题了,希望能得一解,要是分不够,只要能解决问题,分可再加.Server Error in '/' Application.
--------------------------------------------------------------------------------Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1502: The best overloaded method match for 'System.Data.DataView.DataView(System.Data.DataTable)' has some invalid argumentsSource Error: Line 28: CurPage = 1;
Line 29: //DataTable dt = DB.getShowNewsDataSource();
Line 30: DataView dv = new DataView(DB.getShowNewsDataSource());
Line 31: PagedDataSource ps = new PagedDataSource();
Line 32: ps.DataSource = dv;
<system.web>
<pages validateRequest="false" />
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<!--<authentication mode="Windows"/>-->
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
-->
<customErrors mode="Off">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors> </system.web>
</configuration>DB数据操作类如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
/// <summary>
/// DB 的摘要说明
/// </summary>
public class DB
{
private static OleDbConnection con=new OleDbConnection();
private static OleDbCommand cmd=new OleDbCommand();
private static OleDbDataReader dr;
private static OleDbDataAdapter adp; #region 在服务关闭时将历史来访人数写回数据库中
public static void updateAccessCount(int count)
{
try
{
openConnection();
string strsql = "UPDATE accessCount set count=" + count;
cmd.CommandType = CommandType.Text;
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
finally
{
closeConnection();
}
}
#endregion #region 为新闻读取数据源
public static DataTable getShowNewsDataSource()
{
try
{
openConnection();
adp = new OleDbDataAdapter("SELECT * FROM News ORDER BY id", con);
DataSet ds = new DataSet();
adp.Fill(ds, "News"); return ds.Tables["News"]; }
catch (Exception ex)
{
Console.WriteLine("异常:" + ex.ToString());
}
finally
{
closeConnection();
}
return null;
}
#endregion
调用类如下:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class Show_News : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strpage();
}
}
public void strpage()
{
//int curPage = Convert.ToInt32(this.nowpage.Text);
int CurPage;
if (Request.QueryString["Page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage = 1;
DataTable dt = DB.getShowNewsDataSource();
PagedDataSource ps = new PagedDataSource();
ps.DataSource = dt.DefaultView;
ps.AllowPaging = true;
//每个页面显示的留言数
ps.PageSize = 20;
//this.onepage.Text = ps.PageSize.ToString();
//求留言总数
this.allmsg.Text = ps.DataSourceCount.ToString();
//ps.CurrentPageIndex = curPage - 1;
ps.CurrentPageIndex = CurPage - 1;
//求总页
this.allpage.Text = ps.PageCount.ToString();
//this.allpage1.Text = ps.PageCount.ToString();
this.nowpage.Text = CurPage.ToString();
this.DataList1.DataSource = ps;
this.DataList1.DataBind();
//上一页
if (!ps.IsFirstPage)
prepage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
//下一页
if (!ps.IsLastPage)
nextpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
//第一页
if (!ps.IsFirstPage)
firstpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(1);
if (!ps.IsLastPage)
lastpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(ps.PageCount);
}
}
http://yuyu622-1.at.vwdhosting.net/index.aspx
{
if (con.State == ConnectionState.Closed)
{
con.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["conDB"].ConnectionString;
cmd.Connection = con;
try
{
con.Open();
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
}
Line 37: <%
Line 38: int n = 0;
Line 39: for (int i = 0; i <pro_dt.Rows.Count/4-1; i++)
Line 40: {
Line 41: %>
Source File: d:\Users\yuyu622-1\view_product.aspx Line: 39怎么是显示循环这块报错呢
看看这个吧,你在你自己的机器上无错,可能是因为只有你自己一个人访问,如果在互联网上运行,可能同时会有多个用户访问,static 容易出现错误,
Line 37: <%
Line 38: int n = 0;
Line 39: for (int i = 0; i <pro_dt.Rows.Count/4-1; i++)
Line 40: {
Line 41: %>
Source File: d:\Users\yuyu622-1\view_product.aspx Line: 39
怎么是显示循环这块报错呢当然报错了吧?
for 貌似根本没有执行什么语句,也没有 } 来结束 就直接 %> 了,这样是不行的
//下面是个人签名,呵呵
个人博客http://blog.sithere.net,大部分文章都是收集整理的
Line 37: <%
Line 38: int n = 0;
Line 39: for (int i = 0; i <pro_dt.Rows.Count/4-1; i++)
Line 40: {
Line 41: %>
Source File: d:\Users\yuyu622-1\view_product.aspx Line: 39
怎么是显示循环这块报错呢当然报错了吧?
for 貌似根本没有执行什么语句,也没有 } 来结束 就直接 %> 了,这样是不行的
//下面是个人签名,呵呵
个人博客http://blog.sithere.net,大部分文章都是收集整理的