Questions about web.config of a .NET web service published in TD

Discussion forum about all things Team Developer 5.x and 6.x
chelonet
Argentina
Posts: 18
Joined: 19 Apr 2017, 15:28
Location: Argentina

Questions about web.config of a .NET web service published in TD

Post by chelonet » 16 Apr 2018, 21:30

From a .NET web service published in TD 6.1:

1) How can I know from the service, what is the location of the web.config file?
This considering that the name of the service can change (the person who installs it determines it)
c: \ inetpub \ wwwroot \ [WSname] \

[WSname] is variable

If I run SalFileGetCurrentDirectory it tells me that the directory es C:\Windows\SysWOW64\inetsrv

2) Is there a direct way to read IIS settings without knowing the location of the web.config?
That is, something like SalGetProfileString of the web.config of the service that is running

3) Otherwise, if I get the location of the web.config, to read some settings (such as connectionStrings),
is there any standard function, or should I create functions for reading XML?

4) In the manual, I saw that it is set in <appSetings> "TDInstallationDir". What is this setup for?

5) In the manual, I saw that it is set in <appSetings> "TDSqlIniFile". I could connect to Sql Server if it is set. Is it necessary for something?

6) Are there other predefined settings for <appSetings>?. Is there any direct way to have these settings from the service?

Thanks

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 769
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Questions about web.config of a .NET web service published in TD

Post by Igor Ivanovic » 18 Apr 2018, 06:04

Hi,

As I remember, your options are limited with TD6.x, there are no functions to read the web.config, they were introduced in TD7.0.
For accessing various parts of the web.config I wrote a small function in C# (among others I needed) to get some of the settings I put in the web.config file:

Code: Select all

 public string getAppSetting(string keystr)
 {
    string connstr = System.Configuration.ConfigurationManager.AppSettings[keystr];
    return connstr;
}
I didn't even bother to know the location of the web.config file, ie. it was where it should be and I didn't had any problems.
The two TD settings are what their name says, the TD installation dir path and the sql.ini path.
Just be sure that you use the SQLConnectDotNet which was designed for web services and in which you can pass the connection string and not use the sql.ini configuration at all, instead of the SQLConnect which has a lot of overhead and shouldn't be used in a web service at all.
HTH
Igor Ivanovic
Image

chelonet
Argentina
Posts: 18
Joined: 19 Apr 2017, 15:28
Location: Argentina

Questions about web.config of a .NET web service published in TD

Post by chelonet » 19 Apr 2018, 19:07

Thanks Igor for the response.

I will make sure to use SQLConnectDot

Although TDInstallationDir and TDSqlIniFile are what their name indicates, I do not know why they are necessary, because if they are not, it works the same.

I guess where the web.config should be is in %SystemDrive%\inetpub\wwwroot\[WSname]

Thanks

chelonet
Argentina
Posts: 18
Joined: 19 Apr 2017, 15:28
Location: Argentina

Questions about web.config of a .NET web service published in TD

Post by chelonet » 15 May 2018, 14:42

Hi,

I'm having trouble with SQL error capture in .NET Web Service, when connect to OLDEB to Sql Server (with SqlConnectDotNet).
What I want is to trap the last statement executed, and the error message.
With the last sentence I had no problem.
The problem is with the error message. An example of error message is: “Microsoft SQL Server:156[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'.Microsoft SQL Server:8180[Microsoft][ODBC SQL Server Driver][SQL Server]Statement”

The situation is the following:

To connect to the BD, use:
SqlConnectDotNet(hSql, sConnectionString, '', DBP_PROVIDER_SQLSERVER_OLEDB)

Then:

Code: Select all

On SAM_SessionError
        ! The value of lParam is: 208                                        !!! It’s correct
       Set sLastStatement = SqlGetLastStatement()                          !!! It’s OK, sLastStatement is the last sentence
      !!! I want to get the error message !!!
      Call SqlExtractArgs (wParam, lParam, hSQL, nErr, nPos)                 !!! nErr = 208
      Call SqlGetErrorText (nErr, ErrMsg)                                    !!! ErrMsg = NULL
      Call SqlGetStatementErrorInfo ( hSQL, nErr, ErrMsg, strSqlState  )      !!! ErrMsg = NULL
What statement should be used to get the error message from the BD (Sql Server) with .NET Web Service?

Thanks

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests