Ad
How To Fix 'Incorrect Syntax Near '@P1'.' Error In Laravel
While trying to call a stored procedure function in Laravel, I keep getting this error
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '@P1'. (SQL: exec TestProcedure(울산광역시, 남구, 신정동))
Note that in SSMS this stored procedure works fine when I pass the variables, which are, city, county, and address.
Here is my code in Laravel;
public function filterKoreanAddress(Request $request)
{
$data = $request->all();
$results = DB::select(
'exec TestProcedure(?, ?, ?)',
[
$request->input('city'),
$request->input('county'),
$request->input('address'),
]
);
dd($results);
}
So, did I do anything wrong in the code?
Ad
Answer
try it like this
$results = DB::select(
'exec TestProcedure(?, ?, ?)',
array(
$request->input('city'),
$request->input('county'),
$request->input('address'),
)
);
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad