为什么访问不了SQL数据库 - .NET技术 / C#
public static DataSet ExecuteDataSet(string StrSql)
{
SqlConnection strcon = new SqlConnection(con());
try
{
SqlCommand cmd = new SqlCommand(StrSql, strcon);
cmd.CommandTimeout = 180;
cmd.CommandText = StrSql;
cmd.CommandType = CommandType.Text;
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds);
sda.Dispose();
return ds;
}
catch
{
if (strcon.State == ConnectionState.Open)
strcon.Close();
strcon.Dispose();
return null;
}
finally
{
strcon.Dispose();
if (strcon.State == ConnectionState.Open)
strcon.Close();
}
}
登录的时候 查询 用户名和密码
sb.Append(" Select * from Table_d Where [LoginUser]='" + _LoginUser + "' and [LoginPwd]='" + _LoginPwd + "'");
DataSet _Login_Ds = DbHelper.ExecuteDataSet(sb.ToString());
if (_Login_Ds != null)
{
DataTable _Login_Dt = _Login_Ds.Tables[0];
if (_Login_Dt.Rows.Count > 0)
{
Session["Department"] = _Login_Dt.Rows[0]["Department"].ToStri
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间
Id value state dattime
101 32.3 0 ......