您当前的位置: 首页 >  sql

喜欢猪猪

暂无认证

  • 2浏览

    0关注

    228博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

sql server数据库的原始查询数据,并返回结果

喜欢猪猪 发布时间:2018-05-21 10:20:05 ,浏览量:2

  //调整使用占位符进行处理,时间:2017/9/29                    string strql = @"select * from SYS_User where  username=@username and userpwd=@userpwd ";
                   //创建连接对象                    SqlConnection con = new SqlConnection(strco);
                   SqlDataAdapter da = new SqlDataAdapter(strql, con);
                   //命令                    SqlCommand cmd = da.SelectCommand;
                   cmd.CommandType = CommandType.Text;
                   //sql传参的绑定                    cmd.Parameters.Add(new SqlParameter("@username", txt_UserName.Text));
                   cmd.Parameters.Add(new SqlParameter("@userpwd", txt_Pwd.Text));
                   DataSet ds = new DataSet();
                   da.Fill(ds, "info");
                   DataTable dt = ds.Tables[0];
关注
打赏
1648795721
查看更多评论
立即登录/注册

微信扫码登录

0.0342s