vb.net无法保存 为什么vb保存后打不开( 四 )


DataSet ds = db.executedataset(sqlstr);
DataTable dataTable = ds.Tables[0];
if (dataTable != nulldataTable.Rows.Count0)
{
DataView dataView = dataTable.DefaultView;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dataView;
pds.AllowPaging = true;
pds.PageSize = 2;
pds.CurrentPageIndex = Convert.ToInt32(ViewState["pageindex"].ToString());
lb_pageCount.Text = (Convert.ToInt32(ViewState["pageindex"]) + 1).ToString() + "/" + pds.PageCount.ToString() +
"页";
if (!pds.IsFirstPage)
{
lkPre.Visible = true;
}
else
{
lkPre.Visible = false;
}
if (!pds.IsLastPage)
{
lkNext.Visible = true;
}
else
{
lkNext.Visible = false;
【vb.net无法保存 为什么vb保存后打不开】}
DataList2.DataSource = pds;
DataList2.DataBind();
}
else
{
lkNext.Visible = false;
lkPre.Visible = false;
lb_pageCount.Visible = false;
}
}
protected void IndexChanging(object sender, EventArgs e)
{
string strCommand = ((LinkButton)sender).CommandArgument.ToString();
int pageindex = Convert.ToInt32(ViewState["pageindex"].ToString());
if (strCommand == "pre")
{
pageindex = pageindex - 1;
}
else
{
pageindex = pageindex + 1;
}
ViewState["pageindex"] = pageindex;
BindData(ViewState["aname"].ToString());
}
protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
{
OrderItemInfo item = null;
OrderInfo order = null;
string cmdName = null;
int bookid = 0;
string sqlstr = null;
cmdName = e.CommandName.ToString();
if (cmdName.Equals("buyIt"))
{
bookid = Convert.ToInt32(e.CommandArgument);
sqlstr = "select bookname,price from booklist where id=" + bookid;
}
if (Request.Cookies["loginMessage"] != null)
{
if (Session[Session.SessionID] == null)
{
item = new OrderItemInfo();
order = new OrderInfo();
database db = new database();
SqlDataReader dr = db.executeread(sqlstr);
dr.Read();
item.ProductID = bookid;
item.Name = dr[0].ToString();
item.Number = 1;
item.Price = Convert.ToDouble(dr[1]);
order.OrderItemList.Add(item);
order.TotalMoney = item.Price;
order.TotalNumber = item.Number;
Session[Session.SessionID] = order;
}
else
{
order = (OrderInfo)Session[Session.SessionID];
item = new OrderItemInfo();
OrderItemInfo tempItem = null;
int i = 0;
for (i = 0; iorder.OrderItemList.Count; i++)
{
tempItem = (OrderItemInfo)order.OrderItemList[i];
if (tempItem.ProductID == bookid)
{
tempItem.Number++;
order.TotalMoney += tempItem.Price;
break;
}
}
if (i == order.OrderItemList.Count)
{
database db = new database();
SqlDataReader dr = db.executeread(sqlstr);
dr.Read();
item.ProductID = bookid;
item.Name = dr[0].ToString();
item.Number = 1;
item.Price = Convert.ToDouble(dr[1]);
order.OrderItemList.Add(item);
order.TotalMoney += item.Price;
}
order.TotalNumber++;
Session[Session.SessionID] = order;
}
Response.Write("scriptwindow.alert('恭喜您,添加该商品到购物车成功vb.net无法保存!')/script");
}
else
{
Response.Write("scriptwindow.alert('未登陆用户不允许购买商品!')/script");
}
}
}
VB.net怎样保存文件保存文件的步骤为:
关闭流 , 特别是写入流
关闭并保存文件
示例代码如下:
Imports System.Windows.Forms
Imports System.IO
Imports System.Text
Sub SaveFileDemo()

推荐阅读