Web Connection
Web Connection with Ms SQL Server
Gravatar is a globally recognized avatar based on your email address. Web Connection with Ms SQL Server
  Adam W
  All
  Jun 17, 2016 @ 06:59am

I've been reading documentation for couple hours but I still can't figure out how to set my project to use SQL Server connection shared with logging.
Help is inconsistent - in one place it's saying to set it in wconnect.h and when you go there you will see on the top to use wconnect_override.h otherwise when updating in a future it will be gone.
I'm assuming we should not change anything in wconnect.h

So far I did:

  1. run wizard to add tables and SP to my SQL Server database
  2. set my connection string in my project ini file, [MAIN] section
  3. set wconnect_override.h
#UNDEFINE WWC_USE_SQL_SYSTEMFILES    
#DEFINE WWC_USE_SQL_SYSTEMFILES     .T.

PS: Would it be easier to just set it to .T. ? It's been already defined in wconnect.h

  1. Check oSQL object in test Function:
FUNCTION TestPage()
************************
THIS.StandardPage("Hello World from the ltldriverProcess process",;
                  "If you got here, everything is working fine.<p>" + ;
                  "Server Time: <b>" + TIME()+ "</b></p>"+;
                  "<p>oSQL vartype: "+ VARTYPE(Server.oSQL)+;
                  "</p>")
                  
ENDFUNC

  1. Rebuild & run project

Site is not creating oSQL object when starting (oSQL is NULL) ....
What else do I need to set to enforce SQL connection ?

Gravatar is a globally recognized avatar based on your email address. re: Web Connection with Ms SQL Server
  Rick Strahl
  Adam W
  Jun 17, 2016 @ 07:07am

Everything should be set in wconnect_override.h - any values in wconnect.h will get overridden. The values in wconnect_override.h overide the values in wconnect.h. The documentation just mentions where the values are defined.

You have to #UNDEFINE before you can override the value otherwise you get compilation errors. So no you can't just set the value.

Whenever you make a change in the header file you have to recompile your code and all of the Web Connection code that uses these settings, which in this case includes a number of classes. So make sure you kill *.fxp files or else run from the compiled EXE/APP file.

ERASE <wconnect_install_folder)\classes\*.fxp
ERASE <wconnect_install_folder)\*.fxp
COMPILE class <wconnect_install_folder>\classes\*.vcx

You also have to create the database and set the connection string in the YourServer::OnLoad() (the code should be in there already using the configuration setting from yourapp.ini).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Web Connection with Ms SQL Server
  Adam W
  Rick Strahl
  Jun 17, 2016 @ 07:25am

Thank you Rick! That did it !!!
You should mention that somewhere in a documentation otherwise guys like me will be asking the same question over and over 😃

The idea od ini files is so you don't have to recompile but that does not apply to .h files with #DEFINE !
I never use header files (I hate them) for my projects and I forgot about this detail...

Gravatar is a globally recognized avatar based on your email address. re: Web Connection with Ms SQL Server
  Rick Strahl
  Adam W
  Jun 17, 2016 @ 08:10am

There's things that go into 'configuration' and there are things that are 'compiler flags' and this is one that rightfully - IMHO - should be a compiler flag. By using a compiler flag you can exclude that code so you don't pull in stuff that you don't need (like SQL support if you don't use it). This is one of those things you configure once for your app then not again.

Web Connection is pretty old so there's a lot of configuration stuff that's required (no way to do with config flags - like class names, constants etc. It's not the sort of thing that you use at the application layer but it is something that you use at the system layer...

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Web Connection with Ms SQL Server
  Michael B
  Rick Strahl
  Jul 13, 2021 @ 08:36am

Rick,

If I need to connect to an MS SQL server to retrieve data for a custom function, is it OK to just hard code all the settings in the process function itself, or is there a better or proper way to do that?

I am testing with the help of this article - https://webconnection.west-wind.com/docs/_05t05s6b2.htm

But still wanted to ask before I potentially go down the wrong path.

Thank you for all that you do!

MB

Gravatar is a globally recognized avatar based on your email address. re: Web Connection with Ms SQL Server
  Rick Strahl
  Michael B
  Jul 13, 2021 @ 11:07am

Does it work? Sure. Should you do that? No way!

Never ever hardcode paths, connection strings, or any other configurable thing into application code. Set those things in configuration classes and config files so you can change them in one place and preferably without having to recompile your code.

Web Connection has easy tools to create configuration settings. You can use the built-in Web Connection configuration or use your own with wwConfig or even use the XML or JSON serializers with a few lines of code.

+++ Rick ---

© 1996-2021