qq_27852999 2015-08-04 02:32 采纳率: 40%
浏览 1453

winfrom如何使用数据库,求完整代码

我想在窗体中调用数据库,可我忘记代码了,百度也没找到合适的,所以我想求完整代码。不要求三层架构
如何在winfrom里调用sql server数据库,求完整代码

  • 写回答

3条回答 默认 最新

  • 靳小霞 2015-08-04 02:35
    关注

    MySQLConnection conn = null;
    conn = new MySQLConnection(new MySQLConnectionString("58.96.191.232", db_name, "test", "1234", 3306).AsString);
    conn.Open();
    MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
    commn.ExecuteNonQuery();
    string sql = "select uname as 用户名,FROM_UNIXTIME(sh_user_cash.create_time,'%Y-%m-%d %h:%i:%s') as 申请入金时间,amount as 申请入金金额 from sh_user_cash,sh_user where sh_user_cash.cash_type=0 and sh_user_cash.create_time >= (FLOOR((unix_timestamp(now()))/86400)*86400-28800 )AND sh_user_cash.user_id=sh_user.id;"; //当日入金申请查询语句
    MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn);
    DataSet ds = new DataSet();
    mda.Fill(ds, "table1");
    this.dataGridView1.DataSource = ds.Tables["table1"];
    this.tabPage1.Controls.Add(this.dataGridView1);
    conn.Close();

    仅供参考

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置