ADO.net

    string sqlcommand;
            string TextValue = TextBox1.Text.Trim();
            SqlConnection sqlConnection = new SqlConnection("Data Source=61.155.215.29;Initial Catalog=JFX;Persist Security Info=True;User ID=sa;Password=d043fi439yh7ug87GHfgFTfd3HI23efdEWQDE");  //数据库连接字符串
            if (!string.IsNullOrEmpty(TextValue))
            {
                sqlcommand = "select Id,LoginName,BusinessName,Phone,CreateTime From UserInfo where "
                                  + "LoginName=‘" + TextValue + "‘";
            }
            else
            {
                sqlcommand = "select Id,LoginName,BusinessName,Phone,CreateTime From UserInfo";
            }

            sqlConnection.Open();
            

      //DataSet 绑定
            SqlCommand sqlcom = new SqlCommand(sqlcommand);
            SqlDataAdapter da = new SqlDataAdapter(sqlcommand, sqlConnection);
            DataSet ds = new DataSet();
            da.Fill(ds);
            Repeater1.DataSource = ds;

      //DataRead绑定

             SqlCommand sqlcom = new SqlCommand(sqlcommand,sqlConnection);
              SqlDataReader dr = sqlcom.ExecuteReader();

        Repeater1.DataSource = dr;
            Repeater1.DataBind();//数据绑定

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。