zoukankan      html  css  js  c++  java
  • 获取当前插入记录的ID

        其中sql语句写法为:INSERT   INTO   table(a,b)   VALUES   (1,2)   SELECT   @@IDENTITY   AS   'Identity' ,然后用SqlCommand 对象的ExecuteScalar()方法获取即可,下面是写好了的一个函数。

    public static int ExecuteSql(string SQLString)
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand(SQLString, connection))
                    {
                        try
                        {
                            connection.Open();
                            int rows = cmd.ExecuteScalar();
                            return rows;
                        }
                        catch (System.Data.SqlClient.SqlException E)
                        {
                            connection.Close();
                            throw new Exception(E.Message);
                        }
                    }
                }
            } 

  • 相关阅读:
    linux下的make命令
    安装pytorch
    CondaError: Downloaded bytes did not match Content-Length
    cv2.VideoCapture(0)
    cv2.imread(),cv2.imshow(),cv2.imwrite()
    unsqueeze()和squeeze()
    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module
    Can't connect to MySQL server on '127.0.0.1' (10061)
    ping ip
    _vimrc配置
  • 原文地址:https://www.cnblogs.com/catvi/p/1952994.html
Copyright © 2011-2022 走看看