zoukankan      html  css  js  c++  java
  • C#的一些知识

    1、将小数截取到某位小数

    string  str=3.1415926

    string str1=Math.Round(decimal.Parse(str),2) ;//str1为3.14

    2、SQL语句操作数据库

        (1)向数据库中插入或更新

                        SqlConnection myCon = new SqlConnection();
                        myCon.ConnectionString = "Data Source=.;Initial Catalog=JSManager;Integrated Security=True";
                        myCon.Open();

                        SqlCommand myCmd = null;

                        strSql += " INSERT……”

                        myCmd = new SqlCommand(strSql, myCon);
                        myCmd.ExecuteNonQuery();

                        myCon.Close();

       (2)从数据库中查询

                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection = myCon;
                        cmd.CommandText = "Select LogName from TAB_TeacherInfo where Name = '" + teacherName + "'";
                        cmd.CommandType = CommandType.Text;
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.MissingMappingAction = MissingMappingAction.Passthrough;
                        DataTable dt = new DataTable();
                        da.Fill(dt);//这样数据就存在了datatable中

       需要使用时即可从datatable中取, 如dt.Rows[0]["LogName"].ToString()取的即是表中LogName列;dt.Rows.Count得到数据的条数。

  • 相关阅读:
    jQuery小技巧
    HTML5 学习指导
    js对象排序&&倒序
    JS 中如何判断字符串类型的数字
    JavaScript中function的多义性
    JS 继承
    45.oracle表类型、数据拆分、表分区
    44.oracle表空间的使用
    43.oracle同义词
    42.oracle物化视图
  • 原文地址:https://www.cnblogs.com/qingxinblog/p/2834040.html
Copyright © 2011-2022 走看看