Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. OK how do you like this: JavaScript in SQL?

OK how do you like this: JavaScript in SQL?

Scheduled Pinned Locked Moved The Weird and The Wonderful
javascriptdatabasequestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tadas Budvytis
    wrote on last edited by
    #1

    string strSql = "select a.Abr,a.Description As"+ " MaterialType,a.Description,a.code,'" + cm.ChipPath + "'+LEFT(min(m.GraphicID),3)+'/'+min(m.GraphicID)+'.jpg' As ImgPath, " + " Case a.PackageFlag When 'Y' Then '<a href=# " +"onclick=javascript:window.open(&#39;/Page/ShowPackageDetails.aspx" "?PK='+a.Abr+'&#39;,&#39;Package&#39;,&#39;resizable=no,scrollbars=no,width=1000,height=730,left=50,top=50&#39;);>'" + "+a.Description+'</a>' Else a.Description End As MaterialTypeLink " + " from Material_Type a " . . . OK how do you like this: JavaScript in SQL?

    J Y M 3 Replies Last reply
    0
    • T Tadas Budvytis

      string strSql = "select a.Abr,a.Description As"+ " MaterialType,a.Description,a.code,'" + cm.ChipPath + "'+LEFT(min(m.GraphicID),3)+'/'+min(m.GraphicID)+'.jpg' As ImgPath, " + " Case a.PackageFlag When 'Y' Then '<a href=# " +"onclick=javascript:window.open(&#39;/Page/ShowPackageDetails.aspx" "?PK='+a.Abr+'&#39;,&#39;Package&#39;,&#39;resizable=no,scrollbars=no,width=1000,height=730,left=50,top=50&#39;);>'" + "+a.Description+'</a>' Else a.Description End As MaterialTypeLink " + " from Material_Type a " . . . OK how do you like this: JavaScript in SQL?

      J Offline
      J Offline
      J a a n s
      wrote on last edited by
      #2

      Where is the horror? Is it opening a new window in SQL? ;P

      *jaans

      M 1 Reply Last reply
      0
      • J J a a n s

        Where is the horror? Is it opening a new window in SQL? ;P

        *jaans

        M Offline
        M Offline
        MarkB777
        wrote on last edited by
        #3

        Yea.. but its javascript!

        Mark Brock Click here to view my blog

        1 Reply Last reply
        0
        • T Tadas Budvytis

          string strSql = "select a.Abr,a.Description As"+ " MaterialType,a.Description,a.code,'" + cm.ChipPath + "'+LEFT(min(m.GraphicID),3)+'/'+min(m.GraphicID)+'.jpg' As ImgPath, " + " Case a.PackageFlag When 'Y' Then '<a href=# " +"onclick=javascript:window.open(&#39;/Page/ShowPackageDetails.aspx" "?PK='+a.Abr+'&#39;,&#39;Package&#39;,&#39;resizable=no,scrollbars=no,width=1000,height=730,left=50,top=50&#39;);>'" + "+a.Description+'</a>' Else a.Description End As MaterialTypeLink " + " from Material_Type a " . . . OK how do you like this: JavaScript in SQL?

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          Tadas Budvytis wrote:

          OK how do you like this: JavaScript in SQL?

          where is the BEEF :~ I don't see any horror adding JS in sql, but again I don't know the output. I have added js to a code generation. That way I don't have to mack off with the output at the UI level.

          Yusuf

          1 Reply Last reply
          0
          • T Tadas Budvytis

            string strSql = "select a.Abr,a.Description As"+ " MaterialType,a.Description,a.code,'" + cm.ChipPath + "'+LEFT(min(m.GraphicID),3)+'/'+min(m.GraphicID)+'.jpg' As ImgPath, " + " Case a.PackageFlag When 'Y' Then '<a href=# " +"onclick=javascript:window.open(&#39;/Page/ShowPackageDetails.aspx" "?PK='+a.Abr+'&#39;,&#39;Package&#39;,&#39;resizable=no,scrollbars=no,width=1000,height=730,left=50,top=50&#39;);>'" + "+a.Description+'</a>' Else a.Description End As MaterialTypeLink " + " from Material_Type a " . . . OK how do you like this: JavaScript in SQL?

            M Offline
            M Offline
            Mike Dimmick
            wrote on last edited by
            #5

            I agree completely. String substitution in SQL is pretty stupid (it's not very good at string manipulation), non-parameterized SQL queries are very stupid as they're easily subjected to SQL Injection attacks, and both together (and there's a third language here as well, HTML) is just confusing as all hell. I'd split this up into only retrieving actual values from SQL Server using parameterized queries, writing a real JavaScript function that calls window.open, then writing formatted string code to generate the HTML to call the JavaScript function passing the parameters, and passing that through an HTML/XML entity encoding routine where that turns out to be necessary. As it is, that's an unmaintainable mess.

            DoEvents: Generating unexpected recursion since 1991

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups