I am using Application Insights on a web application and it is logging SQL dependencies, but the command listed is not a valid SQL command (AFAICT).
The WebApp is targeting .net 4.6.1 and I'm using Application Insights for Web version 2.1.0. It is collecting data points no problem, but the database dependencies are crazy.
The Command is shown as 'Server | Database'. Here is a copy paste of the Dependency Properties screen.
Dependency Properties
Event time 7/26/2016, 3:08:05 PM
Dependency type SQL
Successful call true
Result code <empty>
Duration 1.66 ms
Command
my-db-servername | my-db-name
Related Items
Request in which this dependency call was made 1
Failed or slow calls to remote dependencies 1
All available telemetry for this operation 2
All available telemetry 5 minutes before and after this event 507
When I try to apply this 'command' using SSMS > new query, it says it is invalid.
We are using Sitefinity for part of the application and it is making 100s to 1000s of calls to the database, each lasting < 1 ms (~500us) and listing the above command as the database command.
At this point I'm not sure whether it is an app insights thing, a sitefinity thing, or something else all together.
However, I'm really interested in why that command is listed as such.
Application Insights command is not a command text. It is concatenated from multiple parameters like this:
If you run stored procedures (4.6+ or (4.0+ StatusMonitor)): server name , pipe, database name, pipe, SPROC name.
If you use StatusMonitor and you run command text: server name , pipe, database name, pipe, command text
If you do not use StatusMontior but have 4.6+ and you run command text: server name , pipe, database name.
I assume your case is 3.
Related
I'm working with Dynamics365 CE in the cloud. I'm trying to run some rather involved queries that I've built up as SQL scripts (using the wonderful "SQL-4-CDS" plugin for the XrmToolBox).
Now I know I can connect to the Dataverse data store through the TDS endpoint (if enabled - it is in my case), and from SSMS, it works just fine:
Server Name = myorg.crm4.dynamics.com,5558
Authentication = Azure Active Directory - Password
User Name = my company e-mail
I can connect to Dataverse, and run my queries - all is great.
Now I'd like to do the same from C# code (running on .NET 6) that I'm writing, that should end up being an Azure Function in the end - so it's a "server-to-server", behind-the-scenes, no interactive login context kind of scenario.
I can connect to Dataverse via the TDS endpoint using this connection string - as long as I'm running the app interactively - as me, in my user context:
Server=myorg.crm4.dynamics.com,5558;Authentication=Active Directory Password;Database=my_dbname;User Id=my_email;Password=my_pwd;
However - this won't work with a server-to-server "daemon"-style setup.
Since I'm using .NET 6 (for the Azure Function), and since I want to run some custom SQL statements, I cannot use the "CRM XRM Client" tooling (with the IOrganizationService classes) - I need to use straight ADO.NET - any idea would I could define an ADO.NET compatible connection string, that would use a Client ID and Client Secret (which I both have at my disposal)?
I've tried a great many values for the Authentication=...... setting - but none have worked so far. Any place I can find a complete list of the supported values for this connection string parameter?
Thanks for any help or pointers!
I am writing a test application in .net using c# to connect to IBM's Informix database.
So far what i did is, i installed Informix client sdk v4.10 in my machine. After that i wrote a piece of code referring from here and here. In my code i have a reference to IBM.Data.Informix.dll which is referred from installed path of Informix client sdk's bin folder netf40.
When i run a test application, i am getting below error while trying to opening up an connection,
ERROR [HY000] [Informix .NET provider][Informix]System error occurred
in network function.
i assume this error is due to connection string field not been supplied properly, i referred https://www.connectionstrings.com/informix/ and tried using connection string like informix with ODBC driver and informix .net provider mentioned in above link but no use, i am also having difficulty in understanding from where to get values for each connection string fields like protocol, port, host-name , server-name and service name.
To find values of above fields, i tried looking for SQLHOSTS key in registry entries under HKEY_LOCAL_MACHINE\SOFTWARE\INFORMIX\ unfortunately it wasn't there! and also tried running setnet32.exe from client sdk's bin folder and i could see below screen with only protocol info!.
It would be really helpful if anyone can help me.
This is a very, very difficult question to answer blind. :-)
setnet32.exe will not know the information you are looking for, you need to provide this information to setnet32.exe.
The first question to ask is: is your database running on Unix or Linux? If it is, then by logging in to the database server as user "informix" and running the command
cat $INFORMIXDIR/etc/sqlhosts
If you're on Windows, then login to the Windows server and from a command prompt, run
TYPE %INFORMIXDIR%\etc\sqlhosts
This should give you a file with potentially a bunch of information, you're looking for lines that are not comments and have at least 4 columns. This is my sqlhosts file on a Docker I'm testing:
$ cat $INFORMIXDIR/etc/sqlhosts
############################################################
### DO NOT MODIFY THIS COMMENT SECTION
### HOST NAME = 7edf3045c382
############################################################
informix onsoctcp 7edf3045c382 9088
informix_dr drsoctcp 7edf3045c382 9089
The last two lines are the guts of the file.
Column 1 is the name of the INFORMIXSERVER or an alias (IBM Informix Server in setnet32.exe)
Column 2 is the protocol name (Protocolname in setnet32.exe)
Column 3 is the host name (HostName in setnet32.exe)
Column 4 is the port number or name (Service name in setnet32.exe)
If column 4 is a name and you're on Unix or Linux, then search for the port name in /etc/services on your Unix or Linux server. If you're on Windows, then it will be in %windir%\system32\drivers\etc\services (or similar).
Once you have that, you can then run the command
dbaccess
Choose the Database option, followed by the Select option. This should present you with a list of databases, roughly like:
SELECT DATABASE >>
Select a database with the Arrow Keys, or enter a name, then press Return.
------------------------------------------------ Press CTRL-W for Help --------
backbone#informix wallet#informix
cust#informix
retail#informix
sports#informix
sysadmin#informix
sysha#informix
sysmaster#informix
sysuser#informix
sysutils#informix
In general, databases called "sys" are reserved for Informix administration, and may not be actual databases, although you can query them with SELECTs, you probably won't be able to (and really shouldn't!!) INSERT, UPDATE or DELETE or use DDL.
In my database list above, all the sys* databases are Informix administration "databases". Database names are shown in my example in "databasename#informixservername" format.
You should now have all the information you need to access your database.
I'm trying to execute a command from inside a .NET process. The command works just fine in Powershell or a regular command prompt executed by the same user as used for the .NET process.
I am trying to update the RRAS SSTP cert on Windows server 2016 with the following command:
netsh ras set sstp-ssl-cert name=bla.domain.foo
The error I'm getting is the following:
The supplied kernel information version is invalid.
This is the code I'm using to execute from inside a simple .NET console application. Outputting logic omitted for brevity.
using (var powerShellInstance = PowerShell.Create())
{
powerShellInstance.AddScript(command);
powerShellInstance.Invoke();
}
I'm using the .NET framework 4.6.1, I have tried adding a manifest to up the required execution rights but neither that or running as admin manually changes anything.
The application is executed by a scheduled task and if I manually add the required script as a step directly executing with cmd.exe it works like a charm. This is not very clean however, and requires me knowing the cert name when creating the task. There are a million ways I can overcome this issue but for the life of me I don't understand why it doesn't just work from .NET while all other commands I require are working fine.
So, this is not really a PoSH specific thing natively. That error message is more general than specific to .Net use case.
This error message is not unique to what you at doing, especially most recently on Win10. This error has been reported, since the 1703 release, even just when doing things on the file system, like WDS captures, folder creation etc.
Several reasons have been postulated, permissions and the like, but all had to just come up with a workaround (permission fixes, etc.) as you have indicated the you have a million ways to address your use case.
But to get to potential root cause, you need to look deeper at the other Windows event log information, Application, Security, System and PowerShell logs from when you are doing your .Net effort.
Today, for each customer, we deploy same SSRS reports folder and data source folder.
The difference between these folders are the name of each folder and the connection string of the data source.
We are using Report Server 2008 R2.
Is it possible to maintain only one reports and data source folder and change programmatically its connection string on server-side before the report been rendered?
If not, Is it something that can be achieved by changing some logic in reports?
Today we use "shared data source" option.
This is something we've done in our environment - we maintain one set of reports that can be deployed at any client with their own configuration.
You've got a couple of options here. Since you're using a Shared Data Source this makes things easier as you won't need to define a Data Source for each report.
1. Use the rs.exe utility and a script file
rs.exe at Books Online
This program allows you to create script files (in VB.NET) that can interact with a Report Server Web Service. You create a script file (e.g. Deploy.rss) and call the rs.exe program with various parameters, including any custom ones you define:
rs.exe -i DeployReports.rss -s http://server/ReportServer -v DatabaseInstance="SQL" -v DatabaseName="ReportDB" -v ReportFolder="ClientReports"
So this would call a script DeployReports.rss, connect to http://server/ReportServer, with three user defined parameters which could be used to create a data source and the report folder.
In the scipt file you could have something like this:
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
CreateFolder(reportFolder, "Report folder")
CreateFolder(datasourceFolder, "Data source folder")
CreateDataSource()
End Sub
Which can then make Web Service calls like:
rs.CreateFolder(folderName, "/", Nothing)
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
definition.ConnectString = "data source=" + DatabaseInstance + ";initial catalog=" + DatabaseName
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = "SQL"
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
'Use the default prompt string.
definition.Prompt = Nothing
definition.WindowsCredentials = False
Try
rs.CreateDataSource(datasource, datasourcePath, False, definition, Nothing)
Console.WriteLine("Data source {0} created successfully", datasource)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
You haven't specified what version of Reporting Services you're using, so I'm assuming 2008. Please note that there are multiple endpoints that can be used, depending on SQL Server version. The 2005/2008 end point is deprecated in 2008R2 and above but is still usable. Just something to bear in mind when writing your script.
2. Call the SSRS Web Service through an application
Report Server Web Service overview
The same calls that are made from the script above can be made in any other application, too. So you'd just need to add a reference to a Report Server Web Service through WSDL and you can connect to a remote service and call its methods to deploy reports, data sources, etc.
So ultimately you're connecting to the Report Server Web Service, it's just the medium used that you need to think about.
Using a script is easier to get running as it's just running a program from the command line, but writing your own deployment application will certainly give greater flexibility. I would recommend getting the script going, so you understand the process, then migrate this to a bespoke application if required. Good luck!
You can use an Expression Based Connection String to select the correct database. You can base this on a parameter your application passes in, or the UserId global variable. I do believe you need to configure the unattended execution account for this to work.
Note: be careful about the security implications. Realize that if you would pass sensitive data (e.g. passwords) into a parameter, that (a) it will go over the wire, and (b) will be stored in the execution log tables for reporting services.
Well my windows service has to send out automated emails when the sql database has been updated.
How Exactly would i go about doing this? any code or tutorials would really help me
Solution 1 - Using sp_send_dbmail
Here is an example of creating a trigger that sends an email when an INSERT/UPDATE/DELETE event occurs on a specific table:
USE AdventureWorks2008R2;
GO
IF OBJECT_ID ('Sales.reminder2','TR') IS NOT NULL
DROP TRIGGER Sales.reminder2;
GO
CREATE TRIGGER reminder2
ON Sales.Customer
AFTER INSERT, UPDATE, DELETE
AS
EXEC msdb.dbo.sp_send_dbmail
#profile_name = 'AdventureWorks2008R2 Administrator',
#recipients = 'danw#Adventure-Works.com',
#body = 'Don''t forget to print a report for the sales force.',
#subject = 'Reminder';
GO
Source: http://msdn.microsoft.com/en-us/library/ms189799.aspx
sp_send_dbmail was introduced in SQL Server 2005. More info: http://msdn.microsoft.com/en-us/library/ms190307.aspx
Note:
Before use, Database Mail must be enabled using the Database Mail
Configuration Wizard, the SQL Server Surface Area Configuration tool,
or sp_configure.
Solution 2 - Using xp_cmdshell
If you can't set up Database Mail you have another option: xp_cmdshell.
With it you can run command line commands within SQL statements e.g. a small email sending tool.
This one is a small example how to send emails using System.Net.Mail in a C# application: http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
How to use xp_cmdshell: http://msdn.microsoft.com/en-us/library/aa260689%28v=sql.80%29.aspx
So you create a small C# console app that sends email then you execute it with xp_cmdshell right from your SQL statement.
Solution 3 - Using a windows service (as he wants)
A Windows Service can't determine by itself whether a rows gets updated in an MSSQL database. You need to log the changes. To do so you may create an trigger for a specific table to record changes. By recording changes I mean inserting a new row into a log table withing the trigger like this:
USE MyDatabase;
GO
IF OBJECT_ID ('Products.TRRowUpdated','TR') IS NOT NULL
DROP TRIGGER Products.TRRowUpdated;
GO
CREATE TRIGGER TRRowUpdated
ON Products
AFTER INSERT, UPDATE, DELETE
AS
INSERT INTO log ('Message', 'Date') VALUES ('Products table got modified', GETTIME())
GO
Creating a Windows Service Project is as easy as creating a Console Application using Visual Studio.
Your service will then read the 'log' table like every minute and send out emails if there were any rows in it (and deletes them of course).
It is possible to determine what kind of change happened: INSERT, UPDATE or DELETE. See the comments on this site for more details: http://msdn.microsoft.com/en-us/library/ms189799.aspx