您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

.net中即时消息发送的实现

作者:佚名    信息学院来源:整理    点击数:    更新时间:2008-1-30 我要参与讨论

    数据库设计:info表:id fromstu_id tostu_id content term
  其中id是主键,fromstu_id是发送信息的用户的学号(这是和我做的学友录连在一起的),tostu_id是接受信息的用户的学号,content是消息的内容,term是判断是否为新消息。
  下面的代码家在校友录中的if not ispostback中
  '/////////////////////判断是否有新留言,将自动弹出页面
  这里还要将页面的刷新时间设置一下,以便可以循环的读取信息。
   Dim mysql As String = "select * from info where tostu_id=@myid and term=1"
   Dim comm As SqlCommand = New SqlCommand(mysql, conn)
   comm.Parameters.Add(New SqlParameter("@myid", SqlDbType.Int, 4))
   comm.Parameters("@myid").Value = Session("stu_id")
   Dim dr As SqlDataReader
   conn.Open()
   dr = comm.ExecuteReader
   If dr.Read Then
   Response.Write("<script language=JavaScript>window.open('info.aspx','','height=330,width=560,
status=no,location=no,toolbar=no,directories=no,menubar=no')</script>")
   End If
   dr.Close()
   comm.Cancel()
  
  下面的代码是用来发送即时消息的页面,其中里面分了两个部分,一个是用来回复的,一个是用来专门发送的,两个的页面稍有区别,仔细看一下就会明白的:)
  
  下面是所有的代码:codebehind部分
  Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   If Not IsPostBack Then
   Dim tostu_id As String = Request.QueryString("tostu_id")
   If tostu_id = "" Then
   '//////////////////当回复留言时
   Dim sql As String = "select a.*,b.nick from info a,pwd b where a.fromstu_id=b.stu_id and a.tostu_id='" & Session("stu_id") & "' and a

[1] [2] [3] [4] [5] [6] [7] 下一页

在google里搜索更多.net中即时消息发送的实现

Google
Web www.51ec.org
  • 上一篇信息学院:

  • 下一篇信息学院:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    我来说两句 对此文章发表了评论
      昵 称: *必填    ·注册用户·
      评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
    评 论
    内 容

     
    评论列表 (最新 评论仅限网友观点!)

    供求信息




    | 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明