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. General Programming
  3. Visual Basic
  4. Calling Stored SQL Functions from Visual Basic

Calling Stored SQL Functions from Visual Basic

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabasesql-server
4 Posts 3 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.
  • M Offline
    M Offline
    Mark Cabbage
    wrote on last edited by
    #1

    Hi Everyone, Wasn't sure if this was a VB or SQL question and where to post so I am trying here. I read it is better to use stored procedures and functions on the SQL server to centralise and re-use code, as well as allowing us to restrict rights to EXECUTE rather than full rights. I wanted to retrieve (and maybe in another function SET), some data so I wrote the following basic function and stored it on the server. My problem is that no matter how I try, I can't seem to find a way to call the function from my VB.NET 2005 application. Please help ALTER FUNCTION dbo.GetEmployeeFont ( @EmployeeID int ) RETURNS TABLE AS RETURN (SELECT FontName, FontSize FROM tblEmployees WHERE (EmployeeID = @EmployeeID))

    C D 2 Replies Last reply
    0
    • M Mark Cabbage

      Hi Everyone, Wasn't sure if this was a VB or SQL question and where to post so I am trying here. I read it is better to use stored procedures and functions on the SQL server to centralise and re-use code, as well as allowing us to restrict rights to EXECUTE rather than full rights. I wanted to retrieve (and maybe in another function SET), some data so I wrote the following basic function and stored it on the server. My problem is that no matter how I try, I can't seem to find a way to call the function from my VB.NET 2005 application. Please help ALTER FUNCTION dbo.GetEmployeeFont ( @EmployeeID int ) RETURNS TABLE AS RETURN (SELECT FontName, FontSize FROM tblEmployees WHERE (EmployeeID = @EmployeeID))

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      That would be better as a stored procedure if you are going to call it from VB


      Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

      1 Reply Last reply
      0
      • M Mark Cabbage

        Hi Everyone, Wasn't sure if this was a VB or SQL question and where to post so I am trying here. I read it is better to use stored procedures and functions on the SQL server to centralise and re-use code, as well as allowing us to restrict rights to EXECUTE rather than full rights. I wanted to retrieve (and maybe in another function SET), some data so I wrote the following basic function and stored it on the server. My problem is that no matter how I try, I can't seem to find a way to call the function from my VB.NET 2005 application. Please help ALTER FUNCTION dbo.GetEmployeeFont ( @EmployeeID int ) RETURNS TABLE AS RETURN (SELECT FontName, FontSize FROM tblEmployees WHERE (EmployeeID = @EmployeeID))

        D Offline
        D Offline
        Duncan Edwards Jones
        wrote on last edited by
        #3

        To call a function in T-SQL you would do e.g. : SELECT * FROM dbo.GetEmployeeFont(2100) To call a stored prcoedure: EXECUTE dbo.GetEmployeeFont 2100 So first you need to know whether you are intending to use a function or a stored proc...

        '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

        M 1 Reply Last reply
        0
        • D Duncan Edwards Jones

          To call a function in T-SQL you would do e.g. : SELECT * FROM dbo.GetEmployeeFont(2100) To call a stored prcoedure: EXECUTE dbo.GetEmployeeFont 2100 So first you need to know whether you are intending to use a function or a stored proc...

          '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

          M Offline
          M Offline
          Mark Cabbage
          wrote on last edited by
          #4

          Thanks Duncan. I need to return some values and use them so I think the function would be best. Excuse my ignorance but my previous coding was for MSAcess so I"m trying to learn SQL server issues, and move from VBA to VB.NET. I have put in the SELECT statement you sugessted but the compiler tells me "Select CASE must end with a matching END SELECT", and hovering over FROM in the statement gives me "name not declared" . Obviously I need more code to setup the SQL statement - could you kindly give me an example please. Many thanks Mark

          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