0

I'm trying to implement import from XLS file to Orders table in my Laravel project with SQL server database. For this purpose I use Laravel Excell package: https://laravel-excel.maatwebsite.nl/ .

I get following error while trying to test an upload:

PDOException (25000)

SQLSTATE[25000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot >>roll back trans2. No transaction or savepoint of that name was found.

The code line with importing is this:

    Excel::import(new OrdersImport, $request->file('file'));

The code for OrdersImport is this:

    class OrdersImport implements ToModel, WithHeadingRow
    {
        /**
        * @param array $row
        *
        * @return \Illuminate\Database\Eloquent\Model|null
        */
        public function model(array $row)
        {
            return new Order([
                'name'     => $row['name'],
                'due_date'    => $row['due_date'],
                'quantity'    => $row['quantity'],
                'id_item'    => $row['id_item'],
                'id_client'    => $row['id_client'],
            ]);
        }
    }

Any ideas what to do?

2 Answers 2

2

I solved this. Just switched my project to MySQL, then got other validation error (date format is not correct). After I made it work on MySQL I switched back to SQL Server and got no more errors.

Sign up to request clarification or add additional context in comments.

Comments

0

check your column data type and make sure you remove the excel header(or enable it from Laravel Excell package)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.