| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2293 人关注过本帖
标题:在没有任何数据时进行无效的读取尝试。
只看楼主 加入收藏
岳艳玲
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-12-9
收藏
 问题点数:0 回复次数:1 
在没有任何数据时进行无效的读取尝试。
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;
using System.Data.SqlClient;

public partial class huifuliuyancaozuo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string str = "server=.\\SQLEXPRESS;database=xinwen;Trusted_Connection=true";
            SqlConnection con = new SqlConnection(str);
            con.Open();
            string str1 = "select liuyanren,liuyanzhuti from liuyan where liuyanren='" + Request.QueryString["liuyanren"] + "'";
            SqlCommand com = new SqlCommand(str1, con);
            SqlDataReader reader = com.ExecuteReader();//定义数据阅读器来读取记录
            reader.Read();//使其读取第一条记录
            //设定文本框控件显示读取到的信息
            TextBox1.Text = reader.GetString(0);
            TextBox2.Text = reader.GetString(1);
            reader.Close();
            con.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = "server=.\\SQLEXPRESS;database=xinwen;Trusted_Connection=true";
        SqlConnection con = new SqlConnection(str);
        con.Open();
        string str1 = "select * from huifuliuyan values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "','" + TextBox3.Text + "','" + txtDate.Text + "')";
        SqlCommand com = new SqlCommand(str1, con);
        if (com.ExecuteNonQuery() > 0)//判断受影响的行数是否大于0,如果大于0,表示数据成功插入到表中,
            Response.Write("<script>alert('回复成功!');window.location='GLY.aspx';</script>");

        else
            Response.Write("<script>alert('回复失败!');</script>");
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBox2_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBox4_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBox3_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBox3_TextChanged1(object sender, EventArgs e)
    {

    }
    protected void txtDate_TextChanged(object sender, EventArgs e)
    {

    }
}
搜索更多相关主题的帖子: public 
2014-12-09 21:36
岳艳玲
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-12-9
收藏
得分:0 
麻烦大家帮我看一下,该怎么办啊
2014-12-09 21:37
快速回复:在没有任何数据时进行无效的读取尝试。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017428 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved