System.Data.Common.DbConnection.Open C# (CSharp) Method

Open() public abstract method

public abstract Open ( ) : void
return void
        public abstract void Open();

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// 初次使用创建数据库
        /// </summary>
        public static void CreateDataBase()
        {
            try
            {
                bool isExist = File.Exists(DataPath);
                if (!isExist)
                {
                    SQLiteConnection.CreateFile(DataPath);
                }
                conn = new SQLiteConnection(ConnStr);
                conn.Open();
                comm = conn.CreateCommand();
                if (!isExist)
                {
                    String sql = "Create table ReceiveData(DeviceNum INTEGER , Temperature INTEGER , Humidity INTEGER , Tyrere INTEGER , MotorState INTEGER , ErrorNum INTEGER , CreateDate DateTime);";
                    comm.CommandText = sql;
                    comm.CommandType = CommandType.Text;
                    comm.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {

            }
        }
All Usage Examples Of System.Data.Common.DbConnection::Open