public override void Open()
        {
            this.InternalConnection = new mysqli(
                host: __SQLiteConnectionStringBuilder.InternalConnectionString.InternalHost,
                user: __SQLiteConnectionStringBuilder.InternalConnectionString.InternalUser,
                password: __SQLiteConnectionStringBuilder.InternalConnectionString.Password
            );

            //http://php.net/manual/en/mysqli.errno.php

            if (this.InternalConnection.connect_errno != 0)
            {
                var message = new
                {
                    this.InternalConnection.connect_errno,

                    //hint = "Check your credentials!",


                    this.InternalConnection.connect_error,

                    ConnectionString = new
                    {
                        __SQLiteConnectionStringBuilder.InternalConnectionString.InternalHost,
                        __SQLiteConnectionStringBuilder.InternalConnectionString.InternalUser
                    }
                };

                throw new Exception(
                    message.ToString()
                );
            }

            this.InternalConnection.query(
                "CREATE DATABASE IF NOT EXISTS `" + __SQLiteConnectionStringBuilder.InternalConnectionString.DataSource + "`"
            );

            if (this.InternalConnection.errno != 0)
            {
                var message = new
                {
                    this.InternalConnection.errno,

                    hint = "Check your credentials!",


                    this.InternalConnection.error,
                };

                throw new Exception(
                    message.ToString()
                );
            }

            this.InternalConnection.query(
                "use `" + __SQLiteConnectionStringBuilder.InternalConnectionString.DataSource + "`"
            );
        }
Пример #2
0
        public __SQLiteDataReader ExecuteReader()
        {
            InternalCreateStatement();

            var r = default(mysqli_result);
            var s = default(mysqli_stmt);

            if (this.InternalPreparedStatement != null)
            {
                this.InternalPreparedStatement.execute();



                // http://stackoverflow.com/questions/13659856/fatal-error-call-to-undefined-method-mysqli-stmtget-result
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2013/201301/20130101

                //r = this.InternalPreparedStatement.get_result() as mysqli_result;
                s = this.InternalPreparedStatement;

                if (s.errno != 0)
                {
                    var message = new { s.errno, s.error };

                    throw new Exception(message.ToString());
                }

                s.store_result();

                //Console.WriteLine("ExecuteReader: " + new { this.InternalPreparedStatement.num_rows, this.InternalPreparedStatement.field_count });
            }
            else
            {
                r = this.c.InternalConnection.query(this.CommandText) as mysqli_result;

                if (this.c.InternalConnection.errno != 0)
                {
                    var message = new { this.c.InternalConnection.errno, this.c.InternalConnection.error };

                    throw new Exception(message.ToString());
                }
            }



            return new __SQLiteDataReader
            {
                InternalResultSet = r,
                InternalStatement = s
            };
        }
Пример #3
0
        public override int ExecuteNonQuery()
        {
            InternalCreateStatement();

            var r = default(mysqli_result);

            if (this.InternalPreparedStatement != null)
            {
                this.InternalPreparedStatement.execute();

                // do we need this?
                //r = this.InternalPreparedStatement.get_result() as mysqli_result;
            }
            else
            {
                r = this.c.InternalConnection.query(this.CommandText) as mysqli_result;
            }

            if (this.c.InternalConnection.errno != 0)
            {
                var message = new { this.c.InternalConnection.errno, this.c.InternalConnection.error };

                throw new Exception(message.ToString());
            }

            return 0;
        }