Git Product home page Git Product logo

Comments (17)

TimelordUK avatar TimelordUK commented on September 24, 2024

What happens if you use sql.WLongVarChar(value) .....

from node-sqlserver-v8.

skiplogic avatar skiplogic commented on September 24, 2024

That works perfectly, thanks!

from node-sqlserver-v8.

Jeff-14159 avatar Jeff-14159 commented on September 24, 2024

I was getting invalid precision type HY104 (msnodesql v0.1.46) I've since updated to v0.2.10 and now I'm getting this new error message 07002. How does one use the "WLongVarChar" in the above example?

Thanks,
Jeff

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

if you are using a very large string as a parameter

sql.query(conn_str, q, [sql.WLongVarChar(value)], function (err, results) { if(err){ console.log(err); } });

should force the driver to use the correct type .... please provide the example you are trying if this does not work correctly.

from node-sqlserver-v8.

Jeff-14159 avatar Jeff-14159 commented on September 24, 2024

Thanks for explaining working great now. 👍

from node-sqlserver-v8.

Jeff-14159 avatar Jeff-14159 commented on September 24, 2024

Update: I think I might have found a possible cause of this issue.... it would appear that it may not be counting the whitespace/newline characters properly to determine if the type should be a WLongVarChar

I have been able to test this by preforming a count on the sting I'm passing in if it is under 2000 including whitespace then no problem, how ever if the character count is like 1800 + 300 whitespaces then it will error until the character count goes over 2000 then it will start working again.....

In my case I'm storing some html and js into the database for dynamic offline content those naturally have lots of white space from the editor..... and I have a base sql update/insert function so for now I'm checking if length is over 2000 during my query builder and parameterizing process

// data: {uuid: 'unique id', col1Name: 'string', col2Name: 'string', col3Name: 'string'};
// dataProps: ['uuid', 'col1Name', 'col2name'] // is an array of filtered propNames to update

var updateQuery = "UPDATE [dbo].[" + tableName + "] SET ";
var updateQueryPrams = [];
for (var i = 0; dataProps.length > i; i++) {
if (dataProps[i] != "uuid") { // exclude the uuid
updateQuery += dataProps[i] + "= ?,";
if (data[dataProps[i]] && data[dataProps[i]].length > 2000) {
updateQueryPrams.push(sql.WLongVarChar(data[dataProps[i]]));
} else {
updateQueryPrams.push(data[dataProps[i]]);
}
}
updateQuery += "lastUpdated = CURRENT_TIMESTAMP";
updateQuery += " where uuid= ?";
updateQueryPrams.push(data.uuid);

sql.query(connStr[database], updateQuery, updateQueryPrams, function (err) {........

Thanks,
Jeff

from node-sqlserver-v8.

CycoPH avatar CycoPH commented on September 24, 2024

I've had this problem when calling a stored procedure. No spaces in the text being stored, but if the text has between 2048 and 8192 characters long then the driver wouth throw an error and go into a completely non-responsive state.

I made sure that my input variables to the stored proc (TEXT) are cast like this:
sql.engine.Text(data.json, data.json.length)

Giving it the correct length right at the beginning makes it work

from node-sqlserver-v8.

philbardem avatar philbardem commented on September 24, 2024

I am having the same issue. This is how I'm calling my stored procedure

const sql = require("mssql/msnodesqlv8")

module.exports = (req, res, next) => {
    var request = new sql.Request(connection)
    request.input("id", sql.Int, req.params.id)
    request.input("page_content", req.body.page_content)
    request.execute("editpage", function(err, rs){
        if (err) console.log(err)
        next()
    })
}

I tried adding:

request.input("page_content", sql.WLongVarChar(65000), req.body.page_content)

and:

request.query("UPDATE pages SET page_content = @page_content, WHERE id = @id", [sql.WLongVarChar(65000)], function(err, rs){
    if (err) console.log(err)
    next()
  })

and I am getting "sql.WLongVarChar is not a function" error. Any adjustments I can make to get this to work? It appears the problem (like Jeff mentions above) happens only between 2000 and 8000 characters or so.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

from node-sqlserver-v8.

philbardem avatar philbardem commented on September 24, 2024

Awesome. Appreciate your help.

from node-sqlserver-v8.

ralfkuh avatar ralfkuh commented on September 24, 2024

I have the same problem, is there a fix coming?

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

this has been fixed please test on 0.6.3

https://github.com/TimelordUK/node-sqlserver-v8/releases/tag/0.6.3

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

I believe this is now fixed so will close. Please reopen if still an issue.

from node-sqlserver-v8.

hobord avatar hobord commented on September 24, 2024

I have the same problem. on 0.6.6...

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on September 24, 2024

from node-sqlserver-v8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.