码迷,mamicode.com
首页 > Web开发 > 详细

ADO.net

时间:2014-09-09 12:20:28      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:io   ar   数据   cti   sp   log   on   c   ad   

    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();//数据绑定

ADO.net

标签:io   ar   数据   cti   sp   log   on   c   ad   

原文地址:http://www.cnblogs.com/fanfh/p/3962044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!