20140909_ADO.net
2014-09-09 09:07 sunny_fan 阅读(137) 评论(0) 收藏 举报 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();//数据绑定
浙公网安备 33010602011771号