shownews2.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:2k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace nspace
- {
- public class MyCodeBehind : Page
- {
- public DataRow dr2;
- public DataRow dr;
- public String newsid;
- public String newsidb;
- //public String ppp;
- //public String newsid3;
- public void Page_Load(Object sender, EventArgs e)
- {
- newsid = Request.Params["id"];
- //ppp = "SELECT typeid FROM aa WHERE typeid = "+newsid;
- //newsidb ="2";
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("candsql.mdb"));
- OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM aa WHERE id="+newsid, myConnection);
- OleDbDataAdapter myCommandb = new OleDbDataAdapter("SELECT * FROM bb WHERE id =(SELECT typeid FROM aa WHERE id = "+newsid+ ")", myConnection);
- DataSet ds = new DataSet();
- DataSet dsb = new DataSet();
- myCommand.Fill(ds, "aa");
- dr = ds.Tables["aa"].Rows[0];
- myCommandb.Fill(dsb, "bb");
- dr2 = dsb.Tables["bb"].Rows[0];
- OleDbCommand myCommand2= new OleDbCommand("select click from aa where id="+newsid,myConnection);
- myCommand2.Connection.Open();
- OleDbDataReader reader = myCommand2.ExecuteReader();
- reader.Read();
- int i = reader.GetInt32(0);
- i++;
- reader.Close();
- myCommand2.CommandText = "UPDATE aa SET click = "+i.ToString()+" WHERE id= "+newsid;
- myCommand2.ExecuteNonQuery();
- myCommand2.Connection.Close();
- myConnection.Close();
- }
- public string FormatString(string str)
- {
- str=str.Replace(" "," ");
- str=str.Replace("<","<");
- str=str.Replace(">",">");
- str=str.Replace('n'.ToString(),"<br>");
- return str;
- }
- }
- }