Open boazlautman opened 4 years ago
` execStr := fmt.Sprintf("exec SP_NAME '%s', '%s', %d", parameter0, parameter2, parameter3) rows, err := c.MssqlDB.Query(execStr) if err != nil { // handle the error }
for rows.Next() {
if err = rows.Scan(&field0, & field1, &field2); err != nil {
// handle the error
}
fmt.Print(field0, field1, field2)
}`
it works on my side
@fhquthpdw Don't do this.
If your parameters are strings, you must escape the value, which is a simple function, but must be done. Alt, you can run:
db.Query("sp_name", sql.Named("Param1", value1), sql.Named("Param2", value2))
With nodejs it is pretty simple In less than 5 minutes i succedded to execute sp https://www.npmjs.com/package/mssql
try { await conx; const request = conx.request(); request.input('CompanyID', sql.Int, compID) request.input('IsActive', sql.Int, IsActive) recordsets = await request.execute('SP_MANAGEMENT_GET_SUPPLIERS_DATA_BY_COMP_ID'); //console.log(recordsets); return recordsets; } catch (error) { console.log(error); // handle error here }
what is the golang equivalent?