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?

jarlh
  • 42,561
  • 8
  • 45
  • 63
TheVic
  • 303
  • 6
  • 16

2 Answers2

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.

TheVic
  • 303
  • 6
  • 16
0

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

Hussam Adil
  • 502
  • 7
  • 13