怎么写的???

解决方案 »

  1.   

    执行SELECT COUNT(*) FROM TB 如果返回0就弹出你需要的那个窗口还有一个方法是返回受影响的行数也行EXECUTENONQUERY这个吧,忘写了
      

  2.   

    最简单的方法:
    如:
    protected void btnSearch_Click(object sender,EventArgs e)
    {
      if(没有查到)
      { 
         Response.Write("<script>alter('没有找到!');</script>");
       }}
      

  3.   

    最简单的方法:
    如:
    protected void btnSearch_Click(object sender,EventArgs e)
    {
      if(没有查到)
      {
        Response.Write(" <script>alert('没有找到!'); </script>");
      }}
    如果使用了asp.net ajax框架,那么还可以这样:protected void btnSearch_Click(object sender,EventArgs e)
    {
      if(没有查到)
      { 
    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "UpdatePanel1", "alert('没有找到!')", true);
    }
      

  4.   

    LS回答分为两派,我也搞不清楚LZ问什么了,
      

  5.   

    using(SqlConnection conn=new SqlConnection(""))
    {
        string strSql="SELECT isnull(count(*),0) from table where 1="1:; 
        SqlCommand cmd=new SqlCommand(strsql,conn); 
        conn.Open(); 
        SqlDataReader reader=cmd.ExecuteReader(); 
        if(reader.Read())
        {
            if((int)reader[0]<=0)ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' defer>alert('');</script>");
            }
         }       
      reader.Close(); 
      conn.Close(); 
    }
      

  6.   

    private void button1_Click(object sender, EventArgs e)
            {
                string connstr = @"Data Source=.\sqlexpress;Initial Catalog=temp;Integrated Security=True";
                SqlConnection connection=new SqlConnection(connstr);
                try
                {
                    string sql = "select count(*) from A";
                    SqlCommand command = new SqlCommand(sql,connection);
                    connection.Open();
                    int result = (int)command.ExecuteScalar();
                    if (result > 0)
                    {
                        //do something
                    }
                    else
                    {
                        MessageBox.Show("没查到?");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
      

  7.   

    protected void btnSearch_Click(object sender,EventArgs e) 

      if(没有查到) 
      { 
        Response.Write(" <script>window.open('');</script>"); 
      } } 
      

  8.   

    using(SqlConnection conn=new SqlConnection("")) 

        string strSql="SELECT isnull(count(*),0) from table where 1="1:; 
        SqlCommand cmd=new SqlCommand(strsql,conn); 
        conn.Open(); 
        SqlDataReader reader=cmd.ExecuteReader(); 
        if(reader.Read()) 
        { 
            if((int)reader[0] <=0)ClientScript.RegisterStartupScript(this.GetType(), "message", " <script language='javascript' defer>alert(''); </script>"); 
            } 
        }      
      reader.Close(); 
      conn.Close(); 
    }
    这个可以啊。
      

  9.   


    private void ConnectDd_1()
        {
            SqlConnection myCon = new SqlConnection();
            myCon.ConnectionString =
                @"Data Source=PC2009102316FKU\NEWSQL;Initial Catalog=my_site;User ID=sa;Password=122159575";
            myCon.Open();
            SqlCommand myCom = new SqlCommand();
            myCom.Connection = myCon;
            myCom.CommandText =
                "select * from management where Username='" + TextBox1.Text.Trim() + "' and Password='" + TextBox2.Text.Trim() + "'";
            SqlDataReader sdr = myCom.ExecuteReader();
            if (sdr.Read())
            {
                sdr.Close();
                myCon.Close();
                Response.Redirect("management.aspx");
            }
            else
            {
                Response.Write(" <script>window.open('密码帐号错误'); </script>");
                Response.Redirect("new_index.aspx");
            }
        }
    [/code]为什么只是我乱输入的东西点登陆,就相当于刷新了一下页面。。没什么窗口弹出啊??把Response.Write(" <script>window.open('密码帐号错误'); </script>");换成Response.Write(" <script>alert('没有找到!'); </script>"); 也不只是刷新